-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[HOLD for payment 2021-12-27] Feature Request - IOU - Holding down the delete button should continually delete the amount - Reported by: @kakajann #6547
Comments
Triggered auto assignment to @jboniface ( |
If you decide to make this one external I would like submit a proposal: To implement the expected behaviour described in the first post on this issue, we can utilize the props
Here is a sample code:
diff --git a/src/components/BigNumberPad.js b/src/components/BigNumberPad.js
index 26299c661..272155c28 100644
--- a/src/components/BigNumberPad.js
+++ b/src/components/BigNumberPad.js
@@ -8,6 +8,17 @@ import Button from './Button';
const propTypes = {
/** Callback to inform parent modal with key pressed */
numberPressed: PropTypes.func.isRequired,
+
+ /** TODO */
+ numberLongPressed: PropTypes.func,
+
+ /** TODO */
+ numberPressOut: PropTypes.func,
+};
+
+const defaultProps = {
+ numberLongPressed: () => {},
+ numberPressOut: () => {},
};
const padNumbers = [
@@ -30,7 +41,9 @@ const BigNumberPad = props => (
key={column}
style={[styles.flex1, marginLeft]}
text={column}
+ onLongPress={() => props.numberLongPressed(column)}
onPress={() => props.numberPressed(column)}
+ onPressOut={props.numberPressOut}
/>
);
})}
@@ -41,5 +54,6 @@ const BigNumberPad = props => (
BigNumberPad.propTypes = propTypes;
BigNumberPad.displayName = 'BigNumberPad';
+BigNumberPad.defaultProps = defaultProps;
export default BigNumberPad;
diff --git a/src/components/Button.js b/src/components/Button.js
index 8e346c963..da0b8cca3 100644
--- a/src/components/Button.js
+++ b/src/components/Button.js
@@ -32,6 +32,12 @@ const propTypes = {
/** A function that is called when the button is clicked on */
onPress: PropTypes.func,
+ /** TODO */
+ onLongPress: PropTypes.func,
+
+ /** TODO */
+ onPressOut: PropTypes.func,
+
/** Call the onPress function when Enter key is pressed */
pressOnEnter: PropTypes.bool,
@@ -68,6 +74,8 @@ const defaultProps = {
small: false,
large: false,
onPress: () => {},
+ onLongPress: () => {},
+ onPressOut: () => {},
pressOnEnter: false,
style: [],
textStyles: [],
@@ -158,6 +166,8 @@ class Button extends Component {
return (
<Pressable
onPress={this.props.onPress}
+ onLongPress={this.props.onLongPress}
+ onPressOut={this.props.onPressOut}
disabled={this.props.isLoading || this.props.isDisabled}
style={[
this.props.isDisabled ? styles.cursorDisabled : {},
diff --git a/src/pages/iou/steps/IOUAmountPage.js b/src/pages/iou/steps/IOUAmountPage.js
index 5f5c2a0ff..4e4b8678e 100755
--- a/src/pages/iou/steps/IOUAmountPage.js
+++ b/src/pages/iou/steps/IOUAmountPage.js
@@ -74,6 +74,8 @@ class IOUAmountPage extends React.Component {
super(props);
this.updateAmountNumberPad = this.updateAmountNumberPad.bind(this);
+ this.handleLongPressNumberPad = this.handleLongPressNumberPad.bind(this);
+ this.clearDeletionTimer = this.clearDeletionTimer.bind(this);
this.updateAmount = this.updateAmount.bind(this);
this.stripCommaFromAmount = this.stripCommaFromAmount.bind(this);
this.focusTextInput = this.focusTextInput.bind(this);
@@ -211,6 +213,8 @@ class IOUAmountPage extends React.Component {
? (
<BigNumberPad
numberPressed={this.updateAmountNumberPad}
+ numberLongPressed={this.handleLongPressNumberPad}
+ numberPressOut={this.clearDeletionTimer}
/>
) : <View />}
/**
* TODO
*
* @param {String} key
*/
handleLongPressNumberPad(key) {
// Backspace button is pressed
if (key !== '<') {
return;
}
const timer = setInterval(() => {
this.setState(prevState => ({
amount: prevState.amount.slice(0, -1),
}));
}, 100);
this.setState({timer});
}
/**
* TODO
*/
clearDeletionTimer() {
clearInterval(this.state.timer);
} Note that I am only checking for the Here is a sample video: 6547-demo.mp4 |
Triggered auto assignment to @bondydaa ( |
posted in our internal slack about how we'd prefer to do this: only allow holding backspace/delete or allow all buttons to repeat if you hold them down. I'm thinking only delete probably makes most sense but wanted to get a gut check there first. |
my thread didn't gain much traction but at least @marcochavezf chimed in and agreed only the backspace/delete button should be able to repeat via holding it down. I think this is fine for a contributor to work on, I'm not super familiar with this code base but I would guess we already have some key event listeners which are blocking the repeat event, unless it's a react native thing (?), because at least on web the default behavior is that keydown events repeat. said differently: I'm not privy enough with this code base to know if @dklymenk suggestion is the right way or not so another engineer who's more familiar should review instead of me. |
Triggered auto assignment to @bfitzexpensify ( |
Upwork posting |
Triggered auto assignment to @parasharrajat ( |
Triggered auto assignment to @iwiznia ( |
Yeah, saw that, but we would still set the timeout... I guess web is the platform we less care about those as I think those have a higher performance impact in mobile, but I think it would be possible to only target native platforms, right? Or is there a case for keeping it to support computers with touchscreens? |
Sorry, I don't see how that would set the timeout. By listening only for I don't think the changes I described above impact the computers with touch screens. We don't render the numpad on desktop, so they cannot press the |
Oh sorry, you are right. |
This is moving along, right @dklymenk? |
No, I haven't been hired on upwork. |
@bfitzexpensify you must've missed my ping, can you hire @dklymenk please? |
Sorry for the delay @dklymenk, hired you now. |
Thank you. I got the offer. I will submit a PR shortly. |
@iwiznia While reviewing the footage for mWeb (#6626) I noticed that when doing a long press on the delete key a completely random UI element gets selected for no reason and an annoying context menu appears. This would definitely qualify as a bug if it were to be merged. I will look into ways of resolving it tomorrow. Thanks. |
Glad to hear that logic is helping out with these problems. I didn't consider that to be reusable while writing it. I will review the PR shortly. |
…-delete #6547 add continious deletion of IOU amount on long press
In review |
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.1.21-1 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue: If no regressions arise, payment will be issued on 2021-12-27. 🎊 |
By looking at the thread above, i'm guessing this job https://www.upwork.com/jobs/Reporting-IOU-Holding-down-the-delete-button-should-continually-delete-the-amount-6547_~011d115cee449bdc46/ is temporary 🤔 |
@bfitzexpensify Thanks, accepted |
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Action Performed:
Expected Result:
Holding down the delete button should continually delete the amount
Actual Result:
Holding down the delete button doesn't continually delete the digits. User has to press each time to delete a single number.
Workaround:
None needed, button is deleting the amount.
Platform:
Where is this issue occurring?
Version Number: 1.1.17-2
Reproducible in staging?: Yes
Reproducible in production?: Yes
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation
Screen_Recording_20211130-171944_New.Expensify.mp4
Expensify/Expensify Issue URL:
Issue reported by: @kakajann
Slack conversation: https://expensify.slack.com/archives/C01GTK53T8Q/p1638274892063400
View all open jobs on GitHub
The text was updated successfully, but these errors were encountered: