You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[HOLD for payment 2023-12-15] [$500] Web - Workspace - Selecting Cancel and pressing Enter key via keyboard updates default currency to USD #32294
Version Number: 1.4.6-1 Reproducible in staging?: Y Reproducible in production?: Y 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:
Prerequisite: Default currency is not set as USD for the workspace
Login to ND Expensify
Navigate to Workspace RHN panel
Click "Bank account"
In Workspace currency popup, Select Cancel via keyboard tab key and press Enter key
Expected Result:
Workspace currency popup is closed without any change to default currency
Actual Result:
Although user selects Cancel and presses Enter key via keyboard, default currency is updated to USD instead of closing the popup
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
changed the title [-]Web - Workspace - Selecting Cancel and pressing Enter key via keyboard updates default currency to USD[/-][+][$500] Web - Workspace - Selecting Cancel and pressing Enter key via keyboard updates default currency to USD[/+]on Nov 30, 2023
This triggers the button press when the "Enter" is pressed no matter what element was focused.
What changes do you think we should make in order to solve the problem?
While applying the pressOnEnter trigger on a Button, we use a specific validation to check whether to submit the button or allow the default event to be fired:
We are already checking if the focused element during pressing Enter is not a textarea (in that case we want to submit the form).
We should also check if the pressed element is not a pressable – and if it is, we'll want to disable the custom hotkey trigger, which will result in firing the default event – triggering the onPress of the focused pressable:
What changes do you think we should make in order to solve the problem?
We should check if the active element has role in the element like button, radio, checkbox, link,... we will not subscribe enter key listen for button
Get activeElement from useActiveElement hook and create a variable like disableEnterShortcut which is true if role of active element is button, radio, ... We should check role instead of dataTag because some elements can have onPress event but dataTag isn't pressable i.e. TextLink
Update isActive here to isActive: pressOnEnter && !shouldDisableEnterShortcut, with this check, we don't need to subscribe enter key in button if active element is clickable element.
OPTION: We can also update this condition in onSubmit function of FormSubmit by checking event.target.role to prevent submitting the form if we are focusing on an element that has onPress event.
For now, I see we pass role props to Pressable, we should update here to role={(props.accessibilityRole ?? props.role) as Role}
So when we focus on the "Cancel' button, and then press ENTER, it also trigger the "Confirm" button `s onPress
What changes do you think we should make in order to solve the problem?
In Slack, once the confirm modal is opened, it will auto-focus on the "Confirm" button for the first time. If we blur it out, so there is no component focused, pressing ENTER does not do anything.
So, we can do like Slack: Disable the pressing ENTER event listener and auto-focus on the "Confirm" for the first time. Do it by:
First, create the useEffect that focuses on the confirm button in the first render in here:
const confirmButtonRef = useRef(null);
useEffect(() => {
// Focus on the Confirm button when the component mounts
if (confirmButtonRef.current) {
confirmButtonRef.current.focus();
}
}, []);
changed the title [-][$500] Web - Workspace - Selecting Cancel and pressing Enter key via keyboard updates default currency to USD[/-][+][HOLD for payment 2023-12-15] [$500] Web - Workspace - Selecting Cancel and pressing Enter key via keyboard updates default currency to USD[/+]on Dec 8, 2023
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.9-5 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 2023-12-15. 🎊
After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.
External issue reporter
Contributor that fixed the issue
Contributor+ that helped on the issue and/or PR
For reference, here are some details about the assignees on this issue:
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
[@ArekChr] The PR that introduced the bug has been identified. Link to the PR:
[@ArekChr] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
[@ArekChr] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
[@ArekChr] Determine if we should create a regression test for this bug.
[@ArekChr] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
[@anmurali] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
Activity
[-]Web - Workspace - Selecting Cancel and pressing Enter key via keyboard updates default currency to USD[/-][+][$500] Web - Workspace - Selecting Cancel and pressing Enter key via keyboard updates default currency to USD[/+]melvin-bot commentedon Nov 30, 2023
Job added to Upwork: https://www.upwork.com/jobs/~01a44752663555a980
melvin-bot commentedon Nov 30, 2023
Triggered auto assignment to @anmurali (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.melvin-bot commentedon Nov 30, 2023
Bug0 Triage Checklist (Main S/O)
Platformsin OP are ✅)melvin-bot commentedon Nov 30, 2023
Triggered auto assignment to Contributor-plus team member for initial proposal review - @ArekChr (
External)bernhardoj commentedon Nov 30, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.=
Pressing enter while focus on the Cancel button will update the currency to USD and close the modal.
What is the root cause of that problem?
In the workspace currency update modal, the Update to USD button has a
pressToEnterprops which will listen to enter key.App/src/components/ConfirmContent.js
Lines 123 to 128 in 56a368b
So, even when we focus on the cancel button, the confirm button press is still triggered.
What changes do you think we should make in order to solve the problem?
Disable the
pressToEnterif there is a cancel button.paultsimura commentedon Nov 30, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.
Pressing enter while focusing on the "Cancel" button triggers the "Confirm" button action
What is the root cause of that problem?
We use
pressOnEnteron the "Confirm" button in the confirmation modal.App/src/components/ConfirmContent.js
Lines 123 to 131 in 56a368b
This triggers the button press when the "Enter" is pressed no matter what element was focused.
What changes do you think we should make in order to solve the problem?
While applying the
pressOnEntertrigger on aButton, we use a specific validation to check whether to submit the button or allow the default event to be fired:App/src/components/Button/index.tsx
Lines 163 to 171 in 7d5f796
We should alter the logic that determines whether the above-mentioned
pressOnEnterwill fire:App/src/components/Button/validateSubmitShortcut/index.ts
Lines 13 to 21 in ec3f466
We are already checking if the focused element during pressing
Enteris not atextarea(in that case we want to submit the form).We should also check if the pressed element is not a
pressable– and if it is, we'll want to disable the custom hotkey trigger, which will result in firing the default event – triggering theonPressof the focusedpressable:Result:
Screen.Recording.2023-11-30.at.20.24.36-compressed.mp4
What alternative solutions did you explore? (Optional)
dukenv0307 commentedon Dec 1, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.
Selecting Cancel and pressing Enter key via keyboard updates default currency to USD
What is the root cause of that problem?
We pass
pressOnEnterfor confirm button and we don't check the active element before triggeringonPressfunction when we press on enter keyApp/src/components/Button/validateSubmitShortcut/index.ts
Line 15 in 6301426
App/src/components/Button/index.tsx
Line 164 in 6301426
What changes do you think we should make in order to solve the problem?
We should check if the active element has
rolein the element likebutton,radio,checkbox,link,... we will not subscribe enter key listen for buttonactiveElementfromuseActiveElementhook and create a variable likedisableEnterShortcutwhich istrueifroleof active element isbutton,radio, ... We should check role instead ofdataTagbecause some elements can haveonPressevent butdataTagisn'tpressablei.e.TextLinkisActivehere toisActive: pressOnEnter && !shouldDisableEnterShortcut, with this check, we don't need to subscribe enter key in button if active element is clickable element.App/src/components/Button/index.tsx
Line 173 in 6301426
OPTION: We can also update this condition in
onSubmitfunction ofFormSubmitby checkingevent.target.roleto prevent submitting the form if we are focusing on an element that hasonPressevent.roleprops toPressable, we should update here torole={(props.accessibilityRole ?? props.role) as Role}App/src/components/Pressable/GenericPressable/index.tsx
Line 17 in 6301426
What alternative solutions did you explore? (Optional)
We can check
event.target.roleinvalidateSubmitShortcutDylanDylann commentedon Dec 1, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.
What is the root cause of that problem?
pressOnEnterthat leads to it will auto triggeronPressfunction once when pressing ENTERApp/src/components/ConfirmContent.js
Lines 123 to 131 in dad6391
What changes do you think we should make in order to solve the problem?
App/src/components/ConfirmContent.js
Line 128 in dad6391
to:
What alternative solutions did you explore? (Optional)
Result
Screencast.from.01-12-2023.17.54.51.webm
25 remaining items
[-][$500] Web - Workspace - Selecting Cancel and pressing Enter key via keyboard updates default currency to USD[/-][+][HOLD for payment 2023-12-15] [$500] Web - Workspace - Selecting Cancel and pressing Enter key via keyboard updates default currency to USD[/+]melvin-bot commentedon Dec 8, 2023
Reviewinglabel has been removed, please complete the "BugZero Checklist".melvin-bot commentedon Dec 8, 2023
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.9-5 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 2023-12-15. 🎊
After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.
For reference, here are some details about the assignees on this issue:
melvin-bot commentedon Dec 8, 2023
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
melvin-bot commentedon Dec 18, 2023
@anmurali, @ArekChr, @mountiny, @dukenv0307 Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
mountiny commentedon Dec 18, 2023
@ArekChr @dukenv0307 could you please handle the checklist before payment?
ArekChr commentedon Dec 18, 2023
Regression test proposal
Do we agree 👍 or 👎
melvin-bot commentedon Dec 19, 2023
@anmurali, @ArekChr, @mountiny, @dukenv0307 Huh... This is 4 days overdue. Who can take care of this?