Skip to content
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 2022-06-15] [$250] Pressing the enter/return key on Request money page, when the button is disabled, takes focus away from the input field - reported by @adeel0202 #8362

Closed
mvtglobally opened this issue Mar 30, 2022 · 35 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor

Comments

@mvtglobally
Copy link

mvtglobally commented Mar 30, 2022

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

  1. Click on + and then Request money option
  2. Press enter key without entering any value in the input field
  3. Now enter some value in the input field
  4. Observe that nothing is being entered in the input field as the focus is no longer on the input field

Expected Result:

Pressing the enter key when the button is disabled should keep the focus on the input field

Actual Result:

Pressing the enter key when the button is disabled takes focus away from the input field

Workaround:

unknown

Platform:

Where is this issue occurring?

  • Web
  • Desktop App

Version Number: 1.1.43-2
Reproducible in staging?: Y
Reproducible in production?: Y
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation

Screen.Recording.2022-03-20.at.6.06.02.PM.mov

Upwork URL: https://www.upwork.com/jobs/~01c7ab5a8744a037c1
Issue reported by: @adeel0202
Slack conversation: https://expensify.slack.com/archives/C01GTK53T8Q/p1647782854047619

View all open jobs on GitHub

@mvtglobally mvtglobally added AutoAssignerTriage Auto assign issues for triage to an available triage team member Daily KSv2 labels Mar 30, 2022
@melvin-bot
Copy link

melvin-bot bot commented Mar 30, 2022

Triggered auto assignment to @conorpendergrast (AutoAssignerTriage), see https://stackoverflow.com/c/expensify/questions/4749 for more details.

@melvin-bot melvin-bot bot removed the AutoAssignerTriage Auto assign issues for triage to an available triage team member label Mar 30, 2022
@conorpendergrast
Copy link
Contributor

I reproduced on Production too, thanks!

@melvin-bot
Copy link

melvin-bot bot commented Mar 31, 2022

Triggered auto assignment to @Beamanator (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.

@Beamanator Beamanator added the External Added to denote the issue can be worked on by a contributor label Mar 31, 2022
@melvin-bot
Copy link

melvin-bot bot commented Mar 31, 2022

Triggered auto assignment to @trjExpensify (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

@Beamanator
Copy link
Contributor

Looks like a good external issue 👍

@melvin-bot
Copy link

melvin-bot bot commented Mar 31, 2022

Triggered auto assignment to Contributor-plus team member for initial proposal review - @rushatgabhane (Exported)

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Mar 31, 2022
@melvin-bot
Copy link

melvin-bot bot commented Mar 31, 2022

Current assignee @Beamanator is eligible for the Exported assigner, not assigning anyone new.

@melvin-bot melvin-bot bot changed the title Pressing the enter/return key on Request money page, when the button is disabled, takes focus away from the input field - reported by @adeel0202 [$250] Pressing the enter/return key on Request money page, when the button is disabled, takes focus away from the input field - reported by @adeel0202 Mar 31, 2022
@trjExpensify
Copy link
Contributor

Job is on Upwork here: https://www.upwork.com/jobs/~01c7ab5a8744a037c1

CC: @adeel0202 if you were interested in this one!

@sobitneupane
Copy link
Contributor

Proposal:
We can achieve the required output by passing prop alwaysFocusIfEmpty in the following component.

<TextInput
disableKeyboard
autoGrow
hideFocusedState
inputStyle={[styles.iouAmountTextInput, styles.p0, styles.noLeftBorderRadius, styles.noRightBorderRadius]}
textInputContainerStyles={[styles.borderNone, styles.noLeftBorderRadius, styles.noRightBorderRadius]}
onChangeText={this.updateAmount}
ref={el => this.textInput = el}
value={formattedAmount}
placeholder={this.props.numberFormat(0)}
keyboardType={CONST.KEYBOARD_TYPE.NUMBER_PAD}
/>

And using the prop in BaseTextInput to focus the input.

componentDidUpdate() {
// Activate or deactivate the label when value is changed programmatically from outside
// Only update when value prop is provided
if (_.isUndefined(this.props.value) || this.state.value === this.props.value) {
return;
}

    componentDidUpdate() {
        // Activate or deactivate the label when value is changed programmatically from outside
        // Only update when value prop is provided
+       if (this.props.alwaysFocusIfEmpty && this.props.value === '') {
+           this.input.focus();
+       }

@rushatgabhane
Copy link
Member

rushatgabhane commented Apr 3, 2022

@sobitneupane wouldn't it be better to focus after onBlur in IOUAmount page?
And is it really necessary to put this in TextInput? Where else do you anticipate this prop being used?

@sobitneupane
Copy link
Contributor

Yes. We can use onBlur function in IOUAmountPage.
Updated Proposal:

    onBlur() {
        if (this.state.amount === '') {
            this.textInput.focus();
        }

<TextInput
disableKeyboard
autoGrow
hideFocusedState
inputStyle={[styles.iouAmountTextInput, styles.p0, styles.noLeftBorderRadius, styles.noRightBorderRadius]}
textInputContainerStyles={[styles.borderNone, styles.noLeftBorderRadius, styles.noRightBorderRadius]}
onChangeText={this.updateAmount}
ref={el => this.textInput = el}
value={formattedAmount}
placeholder={this.props.numberFormat(0)}
keyboardType={CONST.KEYBOARD_TYPE.NUMBER_PAD}
/>

<TextInput
    disableKeyboard
    autoGrow
    hideFocusedState
    inputStyle={[styles.iouAmountTextInput, styles.p0, styles.noLeftBorderRadius, styles.noRightBorderRadius]}
    textInputContainerStyles={[styles.borderNone, styles.noLeftBorderRadius, styles.noRightBorderRadius]}
    onChangeText={this.updateAmount}
    ref={el => this.textInput = el}
    value={formattedAmount}
    placeholder={this.props.numberFormat(0)}
    keyboardType={CONST.KEYBOARD_TYPE.NUMBER_PAD}
+   onBlur = {this.onBlur}
/>

@rushatgabhane
Copy link
Member

And is it really necessary to put this in TextInput
Where else do you anticipate this prop being used

@sobitneupane I didn't mean to say that we should use onBlur, I just wanted your thoughts on where all this prop could be used.

If we can find more than one input where we want this, then we should add a prop to TextInput.

What do you think?

@sobitneupane
Copy link
Contributor

I don't find any other specific use case of the prop. I prefer not to tamper TextInput for now. If we find other places where we want similar behavior than we can pass prop. Rather than onBlur I think we should use EventHandler in IOUAmountPage. If Enter is pressed and there is no amount, textInput remains focused.

setupEventHandlers() {
    if (!document) {
        return;
    }

    this.keyUpHandler = (keyBoardEvent) => {
        // Select the currently highlighted emoji if enter is pressed
        if (keyBoardEvent.key === 'Enter') {
            if (this.state.amount === '') {
                console.log('debug', this.state.amount);
                this.textInput.focus();
            }
            return;
        }
    };

    document.addEventListener('keyup', this.keyUpHandler, true);

}

@rushatgabhane
Copy link
Member

rushatgabhane commented Apr 5, 2022

@sobitneupane I don't like the idea of using event handlers because it isn't really aplicable for native (eg: iPad with a keyboard attached to it).

Why is it better than onBlur?

@sobitneupane
Copy link
Contributor

@sobitneupane I don't like the idea of using event handlers because it isn't really aplicable for native (eg: iPad with a keyboard attached to it).

Why is it better than onBlur?

Oh! In that case, we can go with onBlur. I suggested the event handler because 'Enter' event makes the TextInput blur. So, tried to catch the main cause. In this case, onBlur works fine as well.

@melvin-bot melvin-bot bot added the Overdue label May 12, 2022
@Beamanator Beamanator removed the Help Wanted Apply this label when an issue is open to proposals by contributors label May 12, 2022
@Beamanator
Copy link
Contributor

@sobitneupane can you please check the bug that your PR caused and come up with a new proposal?

@melvin-bot melvin-bot bot removed the Overdue label May 12, 2022
@sobitneupane
Copy link
Contributor

@sobitneupane can you please check the bug that your PR caused and come up with a new proposal?

Strangely, the bug was occurring only for Send Money. The change made by the PR effects other two IOU options Request Money and Split Bill as well. But the other two IOU options were working fine. So, taking a deeper look I found that on pressing the currency, we were redirected to wrong url in case of Send Money. So, following change solves the issue:-

<TouchableOpacity onPress={() => Navigation.navigate(this.props.hasMultipleParticipants
? ROUTES.getIouBillCurrencyRoute(this.props.reportID)
: ROUTES.getIouRequestCurrencyRoute(this.props.reportID))}
>

<TouchableOpacity onPress={() => Navigation.navigate(this.props.hasMultipleParticipants
   ? ROUTES.getIouBillCurrencyRoute(this.props.reportID)
   : this.props.iouType === CONST.IOU.IOU_TYPE.SEND
       ? ROUTES.getIouSendCurrencyRoute(this.props.reportID)
       : ROUTES.getIouRequestCurrencyRoute(this.props.reportID))}
>

After above change:

Screen.Recording.2022-05-12.at.18.52.04.mov

@rushatgabhane
Copy link
Member

@sobitneupane interesting...
I have no idea why that fixes the issue. Maybe you can help me with that :)

@rushatgabhane
Copy link
Member

rushatgabhane commented May 16, 2022

@Beamanator I don't know why it works, but the fix suggested by @sobitneupane is simple #8362 (comment)

There should be no regressions because CurrencySelectionPage just sets a value in Onyx.

@Beamanator
Copy link
Contributor

Good find @sobitneupane and thanks for reviewing @rushatgabhane - lets get that PR up and make sure we understand why it fixes things before we merge again 😅

@mallenexpensify mallenexpensify changed the title [$250] Pressing the enter/return key on Request money page, when the button is disabled, takes focus away from the input field - reported by @adeel0202 [HOLD for payment 2022-05-20][$250] Pressing the enter/return key on Request money page, when the button is disabled, takes focus away from the input field - reported by @adeel0202 May 20, 2022
@mallenexpensify mallenexpensify added the Awaiting Payment Auto-added when associated PR is deployed to production label May 20, 2022
@trjExpensify
Copy link
Contributor

I don't think this is ready to settle up, right? We're waiting on this PR to merge, is that correct @Beamanator @rushatgabhane? #9064 (comment)

@rushatgabhane
Copy link
Member

@trjExpensify yep, that's right!

@trjExpensify trjExpensify removed the Awaiting Payment Auto-added when associated PR is deployed to production label May 23, 2022
@trjExpensify trjExpensify changed the title [HOLD for payment 2022-05-20][$250] Pressing the enter/return key on Request money page, when the button is disabled, takes focus away from the input field - reported by @adeel0202 [$250] Pressing the enter/return key on Request money page, when the button is disabled, takes focus away from the input field - reported by @adeel0202 May 23, 2022
@trjExpensify
Copy link
Contributor

Cool, updated the title and removed the label.

@melvin-bot melvin-bot bot added the Overdue label May 31, 2022
@Beamanator
Copy link
Contributor

Next PR still under review

@melvin-bot melvin-bot bot removed the Overdue label May 31, 2022
@trjExpensify
Copy link
Contributor

PR is waiting to be deployed to staging, Melv. 👍

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jun 8, 2022
@melvin-bot
Copy link

melvin-bot bot commented Jun 8, 2022

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.1.73-2 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 2022-06-15. 🎊

@melvin-bot melvin-bot bot changed the title [$250] Pressing the enter/return key on Request money page, when the button is disabled, takes focus away from the input field - reported by @adeel0202 [HOLD for payment 2022-06-15] [$250] Pressing the enter/return key on Request money page, when the button is disabled, takes focus away from the input field - reported by @adeel0202 Jun 8, 2022
@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jun 14, 2022
@trjExpensify
Copy link
Contributor

Settled up with @sobitneupane, @rushatgabhane & @adeel0202.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

10 participants