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-10-02] [$500] Request money - No autofocus blink cursor shown in Request money page #26994
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)
Close the RHN and again go to fab button -> split bill
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:
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.
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.
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
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
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:
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:
Activity
melvin-bot commentedon Sep 7, 2023
Triggered auto assignment to @NicMendonca (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.melvin-bot commentedon Sep 7, 2023
Bug0 Triage Checklist (Main S/O)
Platformsin OP are ✅)Krishna2323 commentedon Sep 8, 2023
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
onBlurevent is being triggered immediately afteronFocus, 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:
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.
melvin-bot commentedon Sep 11, 2023
@NicMendonca Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
melvin-bot commentedon Sep 11, 2023
@NicMendonca Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
[-]Request money - No autofocus blink cursor shown in Request money page[/-][+][$500] Request money - No autofocus blink cursor shown in Request money page[/+]melvin-bot commentedon Sep 11, 2023
Job added to Upwork: https://www.upwork.com/jobs/~01d0c4dd10133dafa2
melvin-bot commentedon Sep 11, 2023
Current assignee @NicMendonca is eligible for the External assigner, not assigning anyone new.
melvin-bot commentedon Sep 11, 2023
Triggered auto assignment to Contributor-plus team member for initial proposal review - @fedirjh (
External)40 remaining items
[-][$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[/+]melvin-bot commentedon Sep 25, 2023
Reviewinglabel has been removed, please complete the "BugZero Checklist".melvin-bot commentedon Sep 25, 2023
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.
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:
melvin-bot commentedon Sep 25, 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:
NicMendonca commentedon Oct 2, 2023
@fedirjh bump on the BZ issue ^^
NicMendonca commentedon Oct 2, 2023
Reporter: @ashimsharma10 - $50
Contributor: @Krishna2323 - $750
C+ @fedirjh - $750
NicMendonca commentedon Oct 2, 2023
@Krishna2323 @ashimsharma10 - you've both been paid 🎉
@fedirjh can you please accept the offer in Upwork?
Krishna2323 commentedon Oct 2, 2023
@NicMendonca Thank you very much for the bonus, I appreciate it.
NicMendonca commentedon Oct 3, 2023
@fedirjh bump bump on BZ checklist
fedirjh commentedon Oct 3, 2023
BugZero Checklist:
Regression Test Proposal
NicMendonca commentedon Oct 4, 2023
@fedirjh thanks! You've been paid via Upwork🎉
All set here ✅