Skip to content

[HOLD for payment 2024-02-26] [$500] Cursor don't move to next line if return button tapped on keypad after back from referral #35373

Closed

Description

@kavimuru

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: v1.4.33-3
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:

  1. Tap on FAB button >> Start Chat
  2. Click on "Start a Chat, get $250" referral banner
  3. Go back to start chat
  4. Search or select any user
  5. Tap on compose box
  6. Enter any message
  7. Tap on return button on keypad

Expected Result:

After back from referral page, cursor in compose box should move to next line on tapping return button on keypad

Actual Result:

Cursor do not move to next line in compose box on tapping return button on keypad after back from referral page

Note: Issue reproducible on web with SHIFT+Enter & console error shows up (Please check web video attachment)

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

Bug6360432_1706588215346.WEB-Issuerepro_with_console_error.mp4
Bug6360432_1706588215335.RPReplay_Final1706581653_1_.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0150278de70234c5a1
  • Upwork Job ID: 1752280699709931520
  • Last Price Increase: 2024-01-30
  • Automatic offers:
    • aimane-chnaif | Reviewer | 28130727
    • bernhardoj | Contributor | 28130728

Activity

  1. added
    ExternalAdded to denote the issue can be worked on by a contributor
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jan 30, 2024
  2. changed the title [-]Cursor don't move to next line if return button tapped on keypad after back from referral[/-] [+][$500] Cursor don't move to next line if return button tapped on keypad after back from referral[/+] on Jan 30, 2024
  3. melvin-bot commented on Jan 30, 2024

    @melvin-bot
  4. melvin-bot commented on Jan 30, 2024

    @melvin-bot

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

  5. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jan 30, 2024
  6. melvin-bot commented on Jan 30, 2024

    @melvin-bot

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

  7. bernhardoj commented on Jan 30, 2024

    @bernhardoj
    Contributor

    Proposal

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

    Pressing shift enter doesn't add a new line.

    What is the root cause of that problem?

    From the error, we can see that the selectRow from BaseOptionsSelector is still called even after the page is closed, so this.textInput.isFocused() throws an error because the text input is null now. The reason selectRow is still called is because we have a hanging ENTER keyboard shortcut. This happens when we open the referral page, go back, and close the new chat page. Here is what happened:

    We have a focusin listener to disable the enter shortcut whenever an element with a role that is other than PRESENTATION is focused, and enable it in focusout.

    handleFocusIn() {
    const activeElement = document.activeElement;
    this.setState({
    disableEnterShortCut: activeElement && this.accessibilityRoles.includes(activeElement.role) && activeElement.role !== CONST.ROLE.PRESENTATION,
    });
    }
    handleFocusOut() {
    this.setState({
    disableEnterShortCut: false,
    });
    }

    if (prevState.disableEnterShortCut !== this.state.disableEnterShortCut) {
    if (this.state.disableEnterShortCut) {
    this.unsubscribeEnter();
    } else {
    this.subscribeToEnterShortcut();
    }
    }

    But we also "listen" to a focus state and unsubscribe/subscribe it based on the focus state.

    if (prevProps.isFocused !== this.props.isFocused) {
    if (this.props.isFocused) {
    this.subscribeToEnterShortcut();
    this.subscribeToCtrlEnterShortcut();
    } else {
    this.unSubscribeFromKeyboardShortcut();
    }
    }

    When we go back from the referral page, the page gains focus and focusout is also called. So, the enter shortcut is registered twice, but we can only have one instance of the shortcut to unsubscribe when the component unmount.

    this.unsubscribeEnter = KeyboardShortcut.subscribe(

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

    It would be great if the component is migrated to func component so we can use useKeyboardShortcut hook and have a single place to either subscribe/unsubscribe the shortcut. But because we still use class component, we can always make sure the previous shortcut is unregistered before a new one is registered.

    code example:

    if (prevState.disableEnterShortCut !== this.state.disableEnterShortCut) {
        this.unsubscribeEnter();
        if (!this.state.disableEnterShortCut) {
            this.subscribeToEnterShortcut();
        }
    }
    
  8. aimane-chnaif commented on Jan 30, 2024

    @aimane-chnaif
    Contributor

    @bernhardoj's proposal looks good to me.
    This is critical bug many users are facing and reporting. So no need to wait for function component migration (#31739 is on hold for another issue)
    @quinthar @mallenexpensify we finally managed to find clear repro step.
    Let's fix this!

    🎀 👀 🎀 C+ reviewed

  9. melvin-bot commented on Jan 30, 2024

    @melvin-bot

    Triggered auto assignment to @bondydaa, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

  10. 8 remaining items

  11. mallenexpensify commented on Jan 31, 2024

    @mallenexpensify
    Contributor

    Whoohooo... thanks for figuring out the repro steps, 🤞 it's fixed soon. It happened to me again today, I refreshed the page and it starting working again.

  12. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on Feb 19, 2024
  13. changed the title [-][$500] Cursor don't move to next line if return button tapped on keypad after back from referral[/-] [+][HOLD for payment 2024-02-26] [$500] Cursor don't move to next line if return button tapped on keypad after back from referral[/+] on Feb 19, 2024
  14. melvin-bot commented on Feb 19, 2024

    @melvin-bot

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

  15. melvin-bot commented on Feb 19, 2024

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.42-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 2024-02-26. 🎊

    For reference, here are some details about the assignees on this issue:

  16. melvin-bot commented on Feb 19, 2024

    @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:

    • [@aimane-chnaif] The PR that introduced the bug has been identified. Link to the PR:
    • [@aimane-chnaif] 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:
    • [@aimane-chnaif] 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:
    • [@aimane-chnaif] Determine if we should create a regression test for this bug.
    • [@aimane-chnaif] 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.
    • [@abekkala] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
  17. abekkala commented on Feb 21, 2024

    @abekkala
    Contributor

    PAYMENT SUMMARY FOR FEB. 26

    • Issue reported by: Applause internal team
    • Fix: @bernhardoj [$500 - if no regressions] offer
    • PR Review: @aimane-chnaif [$500 - if no regressions] offer please complete checklist
  18. aimane-chnaif commented on Feb 21, 2024

    @aimane-chnaif
    Contributor

    No need regression test. QA team has this test case already.

  19. abekkala commented on Feb 26, 2024

    @abekkala
    Contributor

    @bernhardoj and @aimane-chnaif - payment sent and contracts ended, thank you! 🎉

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