Skip to content

[HOLD for payment 2023-10-02] [$500] Request money - No autofocus blink cursor shown in Request money page #26994

Closed

Description

@izarutskaya

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


Action Performed:

  1. Go to fab button -> request money ->Manual
  2. Notice that there is no blinking cursor beside the currency symbol .
    ( however if the request money page was previously set to scan or distance pages, such behaviour doesn't appear. Thus make sure after clicking request money, manual section is opened automatically)
  3. Close the RHN and again go to fab button -> split bill
  4. Notice that there appears blinking cursor beside currency symbol

Expected Result:

Consistency in pages in split money and request money ( Manual)

Actual Result:

No autofocus blink cursor shown in Request money page

Workaround:

Unknown

Platforms:

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

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

Version Number: v1.3.65-6

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

Notes/Photos/Videos: Any additional supporting documentation

Screen.Recording.2023-09-03.At.5.33.37.Pm.mp4
2023-09-07.22.44.53.mp4

Expensify/Expensify Issue URL:

Issue reported by: @ashimsharma10

Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1693742251468319

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01d0c4dd10133dafa2
  • Upwork Job ID: 1701221973754032128
  • Last Price Increase: 2023-09-11
  • Automatic offers:
    • fedirjh | Reviewer | 26670391
    • Krishna2323 | Contributor | 26670393
    • ashimsharma10 | Reporter | 26670394

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Sep 7, 2023
  2. melvin-bot commented on Sep 7, 2023

    @melvin-bot

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

  3. melvin-bot commented on Sep 7, 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
  4. Krishna2323 commented on Sep 8, 2023

    @Krishna2323
    Contributor

    Proposal

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

    Request money - No autofocus blink cursor shown in Request money page

    What is the root cause of that problem?

    Safari's WebKit rendering engine interacts differently with the JavaScript event queue compared to other browsers. This divergence is particularly evident when programmatically focusing an input element. While InteractionManager.runAfterInteractions() is designed to execute actions after any active animations, its interaction with Safari results in differing behavior. Specifically, Safari may require direct user actions for certain tasks, including focusing on an input, leading to timing inconsistencies in script execution and due to this onBlur event is being triggered immediately after onFocus, and the focus is shifting to the body element, it indicates that there is some external factor causing the TextInput to lose its focus.

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

    To resolve this, we should modify the focusTextInput method by introducing an internal setTimeout function with a delay of 0ms. This ensures the focus command is repositioned to the end of the event queue, effectively navigating around the idiosyncrasies of Safari.

    Reference Code:
    Current Implementation

    Updated Code:

    const focusTextInput = () => {
        // Component may not be initialized due to navigation transitions
        // Wait until interactions are complete before trying to focus
        InteractionManager.runAfterInteractions(() => {
            // Focus text input
            if (!textInput.current) {
                return;
            }
    
            textInput.current.focus();
    
            setTimeout(() => {
                if (!textInput.current) {
                    return;
                }
    
                textInput.current.focus();
            }, 0);
        });
    };
    

    Result

    Screen.Recording.2023-09-08.at.7.21.09.AM.mp4

    Explanation

    Using InteractionManager.runAfterInteractions() inside React Native (or in environments where it's supported) ensures that any work wrapped inside it gets executed after all animations and interactions have finished.

    However, "finished" doesn't always mean "rendered to the screen," especially on some browsers or environments. There might be slight differences in how the browser's rendering engine processes updates to the DOM and how it queues JavaScript events.

    When we're using InteractionManager.runAfterInteractions(), the intended behavior is to delay JavaScript execution until animations have completed, but this does not necessarily guarantee that the browser has completed its rendering process. In Safari's case, the rendering and JavaScript event queues might interact a bit differently than in other browsers.

    By adding the setTimeout with a delay of 0ms, we're essentially placing the focus event at the end of the current JavaScript event queue. Even though the delay is 0ms, it doesn't execute immediately; instead, it waits for the current queue to be emptied. This slight delay, even though minuscule, gives Safari the time it needs to complete the rendering process, ensuring that the focus event works correctly.

    To summarize, while InteractionManager.runAfterInteractions() ensures that JS execution is deferred until animations are done, it doesn't account for potential idiosyncrasies in browser rendering. The nested setTimeout, even with a 0ms delay, provides that extra assurance that the focus will be executed after the rendering process has completed in the Safari browser.

  5. melvin-bot commented on Sep 11, 2023

    @melvin-bot

    @NicMendonca Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  6. melvin-bot commented on Sep 11, 2023

    @melvin-bot

    @NicMendonca Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  7. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Sep 11, 2023
  8. changed the title [-]Request money - No autofocus blink cursor shown in Request money page[/-] [+][$500] Request money - No autofocus blink cursor shown in Request money page[/+] on Sep 11, 2023
  9. melvin-bot commented on Sep 11, 2023

    @melvin-bot
  10. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Sep 11, 2023
  11. melvin-bot commented on Sep 11, 2023

    @melvin-bot

    Current assignee @NicMendonca is eligible for the External assigner, not assigning anyone new.

  12. melvin-bot commented on Sep 11, 2023

    @melvin-bot

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

  13. 40 remaining items

  14. changed the title [-][$500] Request money - No autofocus blink cursor shown in Request money page[/-] [+][HOLD for payment 2023-10-02] [$500] Request money - No autofocus blink cursor shown in Request money page[/+] on Sep 25, 2023
  15. melvin-bot commented on Sep 25, 2023

    @melvin-bot

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

  16. melvin-bot commented on Sep 25, 2023

    @melvin-bot

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

    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:

    As a reminder, here are the bonuses/penalties that should be applied for any External issue:

    • Merged PR within 3 business days of assignment - 50% bonus
    • Merged PR more than 9 business days after assignment - 50% penalty
  17. melvin-bot commented on Sep 25, 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:

    • [@fedirjh] The PR that introduced the bug has been identified. Link to the PR:
    • [@fedirjh] 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:
    • [@fedirjh] 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:
    • [@fedirjh] Determine if we should create a regression test for this bug.
    • [@fedirjh] 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.
    • [@NicMendonca] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
  18. NicMendonca commented on Oct 2, 2023

    @NicMendonca
    Contributor

    @fedirjh bump on the BZ issue ^^

  19. NicMendonca commented on Oct 2, 2023

    @NicMendonca
    Contributor

    Reporter: @ashimsharma10 - $50
    Contributor: @Krishna2323 - $750
    C+ @fedirjh - $750

  20. NicMendonca commented on Oct 2, 2023

    @NicMendonca
    Contributor

    @Krishna2323 @ashimsharma10 - you've both been paid 🎉

    @fedirjh can you please accept the offer in Upwork?

  21. Krishna2323 commented on Oct 2, 2023

    @Krishna2323
    Contributor

    @NicMendonca Thank you very much for the bonus, I appreciate it.

  22. NicMendonca commented on Oct 3, 2023

    @NicMendonca
    Contributor

    @fedirjh bump bump on BZ checklist

  23. fedirjh commented on Oct 3, 2023

    @fedirjh
    Contributor

    BugZero Checklist:


    Regression Test Proposal

    1. Go to fab button -> Request money
    2. Switch to the manual tab
    3. Verify that the amount input is focused and the cursor is blinking.
    • Do we agree 👍 or 👎
  24. NicMendonca commented on Oct 4, 2023

    @NicMendonca
    Contributor

    @fedirjh thanks! You've been paid via Upwork🎉

    All set here ✅

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