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

[$125] Request money - The 'Enter' key fails to select the email/workspace/phone when requesting money. #34239

Closed
1 of 6 tasks
lanitochka17 opened this issue Jan 10, 2024 · 27 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Engineering Help Wanted Apply this label when an issue is open to proposals by contributors Monthly KSv2 Reviewing Has a PR in review

Comments

@lanitochka17
Copy link

lanitochka17 commented Jan 10, 2024

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


Version Number: 1.4.24-0
Reproducible in staging?: Y
Reproducible in production?: N
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
Expensify/Expensify Issue URL:
Issue reported by: Applause - Internal Team
Slack conversation:

Action Performed:

  1. Sign in to staging Expensify
  2. Navigate to FAB > Request Money > Add amount, then press 'Enter' to select the email. Observe that the 'Enter' key does not work as expected

Expected Result:

The 'Enter' key should successfully select the email during the request for money

Actual Result:

The 'Enter' key does not select the email as intended during the request for money

Workaround:

Unknown

Platforms:

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

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6337734_1704896732715.Screen_Recording_2024-01-10_at_5.12.27_AM.mp4

View all open jobs on GitHub

@lanitochka17 lanitochka17 added the DeployBlockerCash This issue or pull request should block deployment label Jan 10, 2024
Copy link
Contributor

👋 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.

Copy link

melvin-bot bot commented Jan 10, 2024

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

@bernhardoj
Copy link
Contributor

bernhardoj commented Jan 10, 2024

Proposal

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

Can't select a participant with the enter key.

What is the root cause of that problem?

This is a regression from #31354.

When we select a participant, we return early if the screen is not focused.

selectFocusedOption(e) {
const focusedItemKey = lodashGet(e, ['target', 'attributes', 'id', 'value']);
const focusedOption = focusedItemKey ? _.find(this.state.allOptions, (option) => option.keyForList === focusedItemKey) : this.state.allOptions[this.state.focusedIndex];
if (!focusedOption || !this.isFocused) {
return;
}

isFocused value initially is false.

and updated true inside the focus listener, but focus listener is called only if the screen is re-focused, not when the page is mounted, so isFocused is always false.

this.focusListener = this.props.navigation.addListener('focus', () => {
// Screen coming back into focus, for example
// when doing Cmd+Shift+K, then Cmd+K, then Cmd+Shift+K.
// Only applies to platforms that support keyboard shortcuts
if ([CONST.PLATFORM.DESKTOP, CONST.PLATFORM.WEB].includes(getPlatform())) {
this.subscribeToKeyboardShortcut();
}
if (this.props.autoFocus && this.textInput) {
this.focusTimeout = setTimeout(() => {
this.textInput.focus();
}, CONST.ANIMATED_TRANSITION);
}
this.isFocused = true;
});

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

We can set the initial value of isFocused to true, but we still need to duplicate the code from the focus listener to the componentDidMount

isFocused is actually not needed because we already unsubscribe the shortcut when component blurs

@youssef-lr youssef-lr changed the title Request money - The 'Enter' key fails to select the email/workspace/phone when requesting money. [$125] Request money - The 'Enter' key fails to select the email/workspace/phone when requesting money. Jan 10, 2024
Copy link

melvin-bot bot commented Jan 10, 2024

⚠️ Could not update price automatically because there is no linked Upwork Job ID. The BZ team member will need to update the price manually in Upwork.

@youssef-lr youssef-lr removed the DeployBlockerCash This issue or pull request should block deployment label Jan 10, 2024
@youssef-lr
Copy link
Contributor

I think this can be demoted.

@youssef-lr youssef-lr added the Bug Something is broken. Auto assigns a BugZero manager. label Jan 10, 2024
Copy link

melvin-bot bot commented Jan 10, 2024

Triggered auto assignment to @johncschuster (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@youssef-lr youssef-lr added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. and removed Bug Something is broken. Auto assigns a BugZero manager. Hourly KSv2 labels Jan 10, 2024
Copy link

melvin-bot bot commented Jan 10, 2024

Current assignee @johncschuster is eligible for the Bug assigner, not assigning anyone new.

@bernhardoj
Copy link
Contributor

@youssef-lr should I raise the PR now?

@situchan
Copy link
Contributor

@hurali97 can you please check this?

@mountiny
Copy link
Contributor

@bernhardoj I have reverted that PR locally and the enter still does not work

@bernhardoj
Copy link
Contributor

@mountiny I tried switching to the commit before the PR and somehow it still didn't work, but after another refresh, the issue is gone.

@mountiny
Copy link
Contributor

interesting, we are reverting it so you can confirm then, thank you!

@situchan
Copy link
Contributor

situchan commented Jan 10, 2024

Interesting. I am not able to reproduce this bug on main but instead enter key doesn't work on amount input page.
Both pages work fine on staging

Screen.Recording.2024-01-11.at.12.11.48.AM.mov

@mountiny
Copy link
Contributor

Oh I was testing the amount page before, that was not fixed with the revert

@situchan
Copy link
Contributor

situchan commented Jan 10, 2024

Seems like the revert introduced this bug as not happening on staging 😄

@youssef-lr
Copy link
Contributor

Yeah I can't reproduce the original issue, but the Enter key in the amount page is broken.

@youssef-lr youssef-lr added Help Wanted Apply this label when an issue is open to proposals by contributors DeployBlockerCash This issue or pull request should block deployment labels Jan 11, 2024
@github-actions github-actions bot added Hourly KSv2 and removed Daily KSv2 labels Jan 11, 2024
Copy link
Contributor

👋 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.

@youssef-lr
Copy link
Contributor

Actually, I can only reproduce locally, but not on staging. Enter key is working fine in both amount page and participants selector.

@youssef-lr youssef-lr removed the DeployBlockerCash This issue or pull request should block deployment label Jan 11, 2024
@situchan
Copy link
Contributor

Actually, I can only reproduce locally, but not on staging. Enter key is working fine in both amount page and participants selector.

yes, this will become deploy blocker on next deploy 😄

@bernhardoj
Copy link
Contributor

The enter doesn't work on the amount page is a regression from #33055

The root cause is similar to the previous issue. The isFocused ref here is initially false and when we set up the config, the isActive is always false.

const config = useMemo(
() => ({
isActive: pressOnEnter && !shouldDisableEnterShortcut && isFocused.current,
shouldBubble: allowBubble,
priority: enterKeyEventListenerPriority,
shouldPreventDefault: false,
}),
// eslint-disable-next-line react-hooks/exhaustive-deps
[shouldDisableEnterShortcut],
);
useKeyboardShortcut(CONST.KEYBOARD_SHORTCUTS.ENTER, keyboardShortcutCallback, config);

Even if the ref is updated, the config memo is never re-calculated.

It's better to use useIsFocused hook just like before the PR and add the focused state to the deps. We don't need to worry that it will re-render the Button component because, in that PR, we already separate the shortcut logic into a separate empty component.

But after fixing this, you will notice that pressing enter will show an invalid amount error and that is because the shortcut callback here is never recreated when onPress instance is updated.

const keyboardShortcutCallback = useCallback(
(event?: GestureResponderEvent | KeyboardEvent) => {
if (!validateSubmitShortcut(isDisabled, isLoading, event)) {
return;
}
onPress();
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[isDisabled, isLoading],
);

The onPress will call submitAndNavigateToNextPage

const submitAndNavigateToNextPage = useCallback(() => {
if (isAmountInvalid(currentAmount)) {
setFormError(translate('iou.error.invalidAmount'));
return;
}

which will check the currentAmount state, but it's always empty when executed inside the shortcut callback.

So, we should add onPress to the shortcut callback deps.

@hurali97
Copy link
Contributor

@bernhardoj Thanks for pin pointing the issue, I have raised a PR fixing this 👍

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Hourly KSv2 labels Jan 11, 2024
Copy link

melvin-bot bot commented Jan 11, 2024

⚠️ 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.

Copy link

melvin-bot bot commented Jan 11, 2024

⚠️ 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.

@mvtglobally
Copy link

Issue not reproducible during KI retests. (First week)

@melvin-bot melvin-bot bot added Monthly KSv2 and removed Weekly KSv2 labels Feb 5, 2024
Copy link

melvin-bot bot commented Feb 5, 2024

This issue has not been updated in over 15 days. @johncschuster, @youssef-lr, @bernhardoj eroding to Monthly issue.

P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

@mvtglobally
Copy link

Issue not reproducible during KI retests. (Second week)

@youssef-lr
Copy link
Contributor

This was fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Engineering Help Wanted Apply this label when an issue is open to proposals by contributors Monthly KSv2 Reviewing Has a PR in review
Projects
None yet
Development

No branches or pull requests

8 participants