Skip to content

[HOLD for payment 2023-12-15] [$500] Web - Workspace - Selecting Cancel and pressing Enter key via keyboard updates default currency to USD #32294

Closed

Description

@lanitochka17

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

  1. Login to ND Expensify
  2. Navigate to Workspace RHN panel
  3. Click "Bank account"
  4. 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?

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

Screenshots/Videos

Add any screenshot/video evidence

Bug6296333_1701367620093.2023-11-30_20-04-19.mp4

Bug6296333_1701367620069!cancel_default_currency

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01a44752663555a980
  • Upwork Job ID: 1730293320039825408
  • Last Price Increase: 2023-11-30
  • Automatic offers:
    • dukenv0307 | Contributor | 27974587
Issue OwnerCurrent Issue Owner: @anmurali

Activity

  1. added
    ExternalAdded to denote the issue can be worked on by a contributor
    BugSomething is broken. Auto assigns a BugZero manager.
    on Nov 30, 2023
  2. 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
  3. melvin-bot commented on Nov 30, 2023

    @melvin-bot
  4. melvin-bot commented on Nov 30, 2023

    @melvin-bot

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

  5. melvin-bot commented on Nov 30, 2023

    @melvin-bot

    Bug0 Triage Checklist (Main S/O)

    • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
    • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
      • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
    • This bug is reproducible using the reproduction steps in the OP. S/O
      • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
      • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
    • This issue is filled out as thoroughly and clearly as possible
      • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
    • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync
  6. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Nov 30, 2023
  7. melvin-bot commented on Nov 30, 2023

    @melvin-bot

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

  8. bernhardoj commented on Nov 30, 2023

    @bernhardoj
    Contributor

    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 pressToEnter props which will listen to enter key.

    <Button
    success={props.success}
    danger={props.danger}
    style={[styles.mt4]}
    onPress={props.onConfirm}
    pressOnEnter

    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 pressToEnter if there is a cancel button.

    pressOnEnter={!props.shouldShowCancelButton}
    
  9. paultsimura commented on Nov 30, 2023

    @paultsimura
    Contributor

    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 pressOnEnter on the "Confirm" button in the confirmation modal.

    <Button
    success={props.success}
    danger={props.danger}
    style={[styles.mt4]}
    onPress={props.onConfirm}
    pressOnEnter
    text={props.confirmText || translate('common.yes')}
    isDisabled={isOffline && props.shouldDisableConfirmButtonWhenOffline}
    />

    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:

    const keyboardShortcutCallback = useCallback(
    (event?: GestureResponderEvent | KeyboardEvent) => {
    if (!validateSubmitShortcut(isFocused, isDisabled, isLoading, event)) {
    return;
    }
    onPress();
    },
    [isDisabled, isFocused, isLoading, onPress],
    );

    We should alter the logic that determines whether the above-mentioned pressOnEnter will fire:

    const validateSubmitShortcut: ValidateSubmitShortcut = (isFocused, isDisabled, isLoading, event) => {
    const eventTarget = event?.target as HTMLElement;
    if (!isFocused || isDisabled || isLoading || eventTarget.nodeName === 'TEXTAREA') {
    return false;
    }
    event?.preventDefault();
    return true;
    };

    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:

        const eventTarget = event?.target as HTMLElement;
    -   if (!isFocused || isDisabled || isLoading || eventTarget.nodeName === 'TEXTAREA') {
    +   if (!isFocused || isDisabled || isLoading || eventTarget.nodeName === 'TEXTAREA' || eventTarget.dataset.tag === 'pressable') {
            return false;
        }

    Result:

    Screen.Recording.2023-11-30.at.20.24.36-compressed.mp4

    What alternative solutions did you explore? (Optional)

  10. dukenv0307 commented on Dec 1, 2023

    @dukenv0307
    Contributor

    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 pressOnEnter for confirm button and we don't check the active element before triggering onPress function when we press on enter key

    if (!isFocused || isDisabled || isLoading || eventTarget.nodeName === 'TEXTAREA') {

    if (!validateSubmitShortcut(isFocused, isDisabled, isLoading, event)) {

    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

    1. 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
    const activeElement = useActiveElement();
    const arrayRole: string[] = Object.values(CONST.ACCESSIBILITY_ROLE);
    const shouldDisableEnterShortcut = arrayRole.includes(activeElement.role) && activeElement.role !== CONST.ACCESSIBILITY_ROLE.TEXT;
    
    1. 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.

    isActive: pressOnEnter,

    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.

    1. For now, I see we pass role props to Pressable, we should update here to role={(props.accessibilityRole ?? props.role) as Role}

    role={props.accessibilityRole as Role}

    What alternative solutions did you explore? (Optional)

    We can check event.target.role in validateSubmitShortcut

  11. DylanDylann commented on Dec 1, 2023

    @DylanDylann
    Contributor

    Proposal

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

    • Web - Workspace - Selecting Cancel and pressing Enter key via keyboard updates default currency to USD

    What is the root cause of that problem?

    • Currently, with the "Confirm" button, we have prop pressOnEnter that leads to it will auto trigger onPress function once when pressing ENTER

    <Button
    success={props.success}
    danger={props.danger}
    style={[styles.mt4]}
    onPress={props.onConfirm}
    pressOnEnter
    text={props.confirmText || translate('common.yes')}
    isDisabled={isOffline && props.shouldDisableConfirmButtonWhenOffline}
    />

    • 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:
    1. 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();
            }
        }, []);
    
    1. Then, update:

      to:
                            pressOnEnter={props.pressOnEnter}     // Can discuss when the pressOnEnter is true or false
    

    What alternative solutions did you explore? (Optional)

    • NA

    Result

    Screencast.from.01-12-2023.17.54.51.webm
  12. 25 remaining items

  13. 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
  14. melvin-bot commented on Dec 8, 2023

    @melvin-bot

    Reviewing label has been removed, please complete the "BugZero Checklist".

  15. melvin-bot commented on Dec 8, 2023

    @melvin-bot

    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:

  16. melvin-bot commented on Dec 8, 2023

    @melvin-bot

    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:
  17. melvin-bot commented on Dec 18, 2023

    @melvin-bot

    @anmurali, @ArekChr, @mountiny, @dukenv0307 Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  18. mountiny commented on Dec 18, 2023

    @mountiny
    Contributor

    @ArekChr @dukenv0307 could you please handle the checklist before payment?

  19. ArekChr commented on Dec 18, 2023

    @ArekChr
    Contributor
    • Link to the PR: No PR with bug identified. It seems this case was never handled
    • Link to comment: n/a
    • Link to discussion: n/a
    • Determine if we should create a regression test for this bug: We can add a regression test to ensure we keep good accessibility practices.

    Regression test proposal

    1. Open App
    2. Navigate to the Workspace RHN panel
    3. Click "Bank account"
    4. Focus Cancel via the keyboard tab key in the Workspace currency popup and press Enter.
    5. Ensure that cancel was pressed instead of Delete (submitting form)

    Do we agree 👍 or 👎

  20. melvin-bot commented on Dec 19, 2023

    @melvin-bot

    @anmurali, @ArekChr, @mountiny, @dukenv0307 Huh... This is 4 days overdue. Who can take care of this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions