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 2023-09-12] [HOLD for payment 2023-09-11] [$500] Request money - Enter key does not move to next page on big number pad page #26588

Closed
1 of 6 tasks
lanitochka17 opened this issue Sep 2, 2023 · 57 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor

Comments

@lanitochka17
Copy link

lanitochka17 commented Sep 2, 2023

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


Issue found when executing PR #26520

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to + > Request money
  3. Enter an amount
  4. Hit Enter on the keyboard

Expected Result:

You can press enter on both, amount and Distance request page to continue to a next step

Actual Result:

Request money flow is not proceeded to the next page

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.3.62-1

Reproducible in staging?: Yes

Reproducible in production?: No

If this was caught during regression testing, add the test name, ID and link from TestRail:

Email or phone of affected tester (no customers):

Logs: https://stackoverflow.com/c/expensify/questions/4856

Notes/Photos/Videos: Any additional supporting documentation

Bug6186267_20230902_234752.mp4

Expensify/Expensify Issue URL:

Issue reported by: Applause - Internal Team

Slack conversation:

View all open jobs on GitHub

@lanitochka17 lanitochka17 added the DeployBlockerCash This issue or pull request should block deployment label Sep 2, 2023
@OSBotify
Copy link
Contributor

OSBotify commented Sep 2, 2023

👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open StagingDeployCash deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.

@melvin-bot
Copy link

melvin-bot bot commented Sep 2, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 3, 2023

⚠️ Looks like this issue was linked to a Deploy Blocker here

If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

If a regression has occurred and you are the assigned CM follow the instructions here.

If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

@mkhutornyi
Copy link
Contributor

mkhutornyi commented Sep 3, 2023

Proposal

Please re-state the problem that we are trying to solve in this issue.

Request money - Enter key does nothing on Manual request amount input page

What is the root cause of that problem?

This came from 5b8cd86 where pressOnEnter prop is added to DistanceRequest. cc: @hayata-suenaga

Then why does this happen?
We render all tabs on Request money page in the order of left > right.
So Distance tab page is rendered after Manual tab page render.
So Button's enter key is subscribed in MoneyRequestAmountForm first. And then DistanceRequest next.
So when user press Enter key, DistanceRequest's button onPress takes precedence over MoneyRequestAmountForm's button.

What changes do you think we should make in order to solve the problem?

Step 1. set pressOnEnter prop value conditionally based on page active status.

const isFocused = useIsFocused();
<Button pressOnEnter={isFocused} />

Step 2. Update Button component to dynamically subscribe/unsubscribe enter key listener based on pressOnEnter prop change.
This logic will be added in componentDidUpdate

What alternative solutions did you explore? (Optional)

remove pressOnEnter prop from DistanceRequest's button

@napster125
Copy link
Contributor

napster125 commented Sep 3, 2023

Proposal

Please re-state the problem that we are trying to solve in this issue.

Request money - Enter key does not move to next page on new money request page.

What is the root cause of that problem?

The root cause of this problem lies within the Button component, specifically in the way the Enter key listener is set up.

componentDidMount() {
if (!this.props.pressOnEnter) {
return;
}
const shortcutConfig = CONST.KEYBOARD_SHORTCUTS.ENTER;
// Setup and attach keypress handler for pressing the button with Enter key
this.unsubscribe = KeyboardShortcut.subscribe(
shortcutConfig.shortcutKey,
(e) => {
if (!validateSubmitShortcut(this.props.isFocused, this.props.isDisabled, this.props.isLoading, e)) {
return;
}
this.props.onPress();
},
shortcutConfig.descriptionKey,
shortcutConfig.modifiers,
true,
false,
this.props.enterKeyEventListenerPriority,
false,
);
}

Currently, this listener is only established during the componentDidMount lifecycle. This issue primarily occurs on the "New Request Money" page because the text field starts empty, causing the isDisabled property to be initially set to true, and subsequently to false as the user inputs data. However, the Button component does not respond to this change in isDisabled during the componentDidUpdate lifecycle, preventing the Enter key event from being properly handled.

It's worth noting that this issue is observed in the development environment but is not likely a regression of commit, as the behavior of the Button component may be expected.

What changes do you think we should make in order to solve the problem?

To resolve this issue, I recommend adding the same logic for setting up the Enter key listener in the componentDidUpdate lifecycle when isDisabled changes. This modification ensures consistent behavior regardless of the initial state of isDisabled.

componentDidMount() {
    this.setupEnterKeyListener();
}
componentDidUpdate(prevProps) {
    if (prevProps.isDisabled === this.props.isDisabled || this.props.isDisabled) {
        return;
    }
    this.setupEnterKeyListener();
}
componentWillUnmount() {
    // Cleanup event listeners
    if (!this.unsubscribe) {
        return;
    }
    this.unsubscribe();
}

What alternative solutions did you explore? (Optional)

n/a

Result

6.mp4

@mountiny
Copy link
Contributor

mountiny commented Sep 3, 2023

@mkhutornyi I think your solution sounds good and I would prefer it over @napster125 proposed way as we dont want to mess with Button component logic right now give its such heavily used component.

Can you describe how you gonna get the isActiveTab?

remove pressOnEnter prop from DistanceRequest's button

this will make it work for other pages, but then it does not work on the Distance request page.

@mountiny
Copy link
Contributor

mountiny commented Sep 3, 2023

I think I will just remove the pressOnEnter now because I am not sure if its trivial to get the tab index. I think we can live without the Enter working on the distance given it will be mainly used on mobile.

@mountiny mountiny assigned mountiny and unassigned marcaaron Sep 3, 2023
@napster125
Copy link
Contributor

@mountiny it's impossible because this line will prevent the enter key event when isDisabled is true.

https://github.com/Expensify/App/blame/52b1e3e9abaabdaf79c0eeafef5665292cf2ab9c/src/components/Button/index.js#L178

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Hourly KSv2 labels Sep 3, 2023
@mountiny
Copy link
Contributor

mountiny commented Sep 3, 2023

@napster125 what is impossible specifically?

@napster125
Copy link
Contributor

@mountiny if so, your PR won't fix this issue. without pressOnEnter, we can't move to next page.

@b4s36t4
Copy link
Contributor

b4s36t4 commented Sep 3, 2023

we can't move to next page.

Even if we click?

@napster125
Copy link
Contributor

napster125 commented Sep 3, 2023

@napster125 what is impossible specifically?

This is from my proposal.

Currently, this listener is only established during the componentDidMount lifecycle. This issue primarily occurs on the "New Request Money" page because the text field starts empty, causing the isDisabled property to be initially set to true, and subsequently to false as the user inputs data. However, the Button component does not respond to this change in isDisabled during the componentDidUpdate lifecycle, preventing the Enter key event from being properly handled.

@mountiny without resolving this, we can't fix the issue when enter key is pressed.

@napster125
Copy link
Contributor

we can't move to next page.

Even if we click?

No, I mean when we press enter key.

@mountiny
Copy link
Contributor

mountiny commented Sep 3, 2023

we can't move to next page.

Yeah I know:

I think I will just remove the pressOnEnter now because I am not sure if its trivial to get the tab index. I think we can live without the Enter working on the distance given it will be mainly used on mobile.

I think that is better given the urgency, basically the flow we need for the conference will be people on their phones mainly so if the enter does not work on the distance page, thats fine, but we prefer to fix this on the other pages.

I would then let this issue to be exported to figure out a general solution which will enable enter on all pages so feel free to think about that

@napster125
Copy link
Contributor

@mountiny if so, we don't need to remove pressOnEnter.

@mkhutornyi
Copy link
Contributor

Can you describe how you gonna get the isActiveTab?

@mountiny It's pretty simple. react-navigation supports useIsFocused for Tab navigator as well

@mkhutornyi
Copy link
Contributor

I can raise PR right now if my solution is acceptable

@dylanexpensify
Copy link
Contributor

Ah got it - @parasharrajat so to confirm:

  • We need to pay you for internal review of PR in deploy blocker?
  • We haven't selected a proposal yet for this issue? cc @thesahindia

Is that right?

@melvin-bot melvin-bot bot removed the Overdue label Sep 19, 2023
@parasharrajat
Copy link
Member

@dylanexpensify Correct.

@mountiny
Copy link
Contributor

What is the bug still left here to solve?

@parasharrajat
Copy link
Member

parasharrajat commented Sep 19, 2023

We disabled the Enter key submission on the Distance Request page to solve this DB which we thought of pursuing further. #26588 (comment)

@mountiny
Copy link
Contributor

Ok, @dylanexpensify maybe we could create a new ticket for this issue so we can keep stuff separate and cleaner.

@parasharrajat
Copy link
Member

parasharrajat commented Sep 19, 2023

In that case, please assign me as C+ here for clarity

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 19, 2023
@dylanexpensify
Copy link
Contributor

Done ^

@dylanexpensify
Copy link
Contributor

@mkhutornyi
Copy link
Contributor

@mountiny Am I eligible for any compensation here? As my proposal (correct root cause and alternative solution) might have helped fixing this deploy blocker.

@parasharrajat
Copy link
Member

@dylanexpensify I will request it.

Did you open the new issue?

@parasharrajat
Copy link
Member

@mkhutornyi Reporting will be paid off when the issue is completely solved.

@melvin-bot melvin-bot bot added the Overdue label Sep 22, 2023
@dylanexpensify
Copy link
Contributor

dylanexpensify commented Sep 22, 2023

@parasharrajat yes here!

@mountiny
Copy link
Contributor

I am confused whats he status on this one, can we close it out?

@melvin-bot melvin-bot bot removed the Overdue label Sep 25, 2023
@b4s36t4
Copy link
Contributor

b4s36t4 commented Sep 25, 2023

@mountiny I think you can close this as there's another issue created for tracking the main issue. #28022

@mountiny
Copy link
Contributor

thanks! Feel free to reopen if closing is not the best path forwards

@parasharrajat
Copy link
Member

Payment requested as per #26588 (comment) #26588 (comment)

@dylanexpensify Can you post the payment summary here? Thanks.

@dylanexpensify
Copy link
Contributor

Payment summary:

@JmillsExpensify
Copy link

$500 payment approved for @parasharrajat based on BZ summary.

@mkhutornyi
Copy link
Contributor

mkhutornyi commented Oct 11, 2023

Am I eligible for any compensation here? As my proposal (correct root cause and alternative solution) might have helped fixing this deploy blocker.


Off topic:
@parasharrajat gave 👎 on my main solution but unfortunately his solution of allowing bubble caused another regression - #29051, while mine wouldn't have caused.

@parasharrajat
Copy link
Member

@mkhutornyi You are eligible on #28022 as discussed before.

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 Bug Something is broken. Auto assigns a BugZero manager. 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