Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HOLD for payment 2023-09-21] Web - Input field not focused on click of back button from Get assistance page #25893

Closed
1 of 6 tasks
izarutskaya opened this issue Aug 24, 2023 · 28 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering

Comments

@izarutskaya
Copy link

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Action Performed:

  1. go to Settings > Workspaces >members
  2. click on invite button
  3. click on ? button to go Get assistance page
  4. click on back button

Expected Result:

input field not focused on click of back button

Actual Result:

input field should be focused on click of back button from Get assistance page

Workaround:

Unknown

Platforms:

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

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

Version Number: v1.3.57-2

Reproducible in staging?: Y

Reproducible in production?: N

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-08-23.At.1.42.51.Pm.mp4
Recording.1320.mp4

Expensify/Expensify Issue URL:

Issue reported by: @gadhiyamanan

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

View all open jobs on GitHub

@izarutskaya izarutskaya added DeployBlockerCash This issue or pull request should block deployment Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Aug 24, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 24, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Aug 24, 2023

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

@OSBotify
Copy link
Contributor

👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open StagingDeployCash deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.

@melvin-bot
Copy link

melvin-bot bot commented Aug 24, 2023

Triggered auto assignment to @grgia (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.

@b4s36t4
Copy link
Contributor

b4s36t4 commented Aug 24, 2023

Proposal

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

This is happening after #22622 this PR, we don't do any focus on the input when navigating back.

What is the root cause of that problem?

After getting merged of #25894 which will allow us to manually focus the input, we can use the updated ref and would be focusing depends on route focus in Screen WorkSpaceInvitePage

const isFocused = props.navigation.isFocused()

useEffect(() => {
    if(selectionListRef.current && isFocused){
        selectListRef.current.focusTextInput()
    }
},[isFocused, selectionListRef])

Would be giving the focus to the input whenever we navigate back.

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

NA

@melvin-bot melvin-bot bot added Daily KSv2 and removed Hourly KSv2 labels Aug 24, 2023
@roryabraham roryabraham added Hourly KSv2 and removed Daily KSv2 labels Aug 25, 2023
@situchan
Copy link
Contributor

@b4s36t4 we should implement "focus input on navigation focus" in BaseSelectionList which is base component, similar to BaseOptionsSelector here:

componentDidUpdate(prevProps) {
if (this.textInput && this.props.autoFocus && !prevProps.isFocused && this.props.isFocused) {
InteractionManager.runAfterInteractions(() => {
// If we automatically focus on a text input when mounting a component,
// let's automatically focus on it when the component updates as well (eg, when navigating back from a page)
this.textInput.focus();
});
}

@b4s36t4
Copy link
Contributor

b4s36t4 commented Aug 25, 2023

@situchan gotcha. I think the same approach would do the work, except in context of functional component and the way we use the props.

@roryabraham roryabraham assigned roryabraham and unassigned grgia Aug 25, 2023
@roryabraham
Copy link
Contributor

This is still reproducible in 1.3.57-5

@roryabraham
Copy link
Contributor

@situchan I tried that actually for a related issue – InteractionsManager.runAfterInteractions uses requestAnimationFrame on web and so will interrupt a transition in progress. I know that's what react-navigation recommends in their docs, but it doesn't really work on web.

I tried this solution and it works great for pushing new routes onto the stack, but doesn't work for popping routes off the stack because, as Satya explains here, transitionStart and transitionEnd only run for the top card on the stack.

In this case we want to run an effect on the new top card on the stack only after transitionEnd finishes for the old top card on the stack.

@roryabraham
Copy link
Contributor

This solution seems to work well for pushing new cards onto the stack as well as popping them:

diff --git a/src/components/SelectionList/BaseSelectionList.js b/src/components/SelectionList/BaseSelectionList.js
index 046b64e9e5..74083c4ad8 100644
--- a/src/components/SelectionList/BaseSelectionList.js
+++ b/src/components/SelectionList/BaseSelectionList.js
@@ -1,7 +1,8 @@
-import React, {useEffect, useMemo, useRef, useState} from 'react';
+import React, {useMemo, useRef, useState, useCallback} from 'react';
 import {View} from 'react-native';
 import _ from 'underscore';
 import lodashGet from 'lodash/get';
+import {useFocusEffect} from '@react-navigation/native';
 import SectionList from '../SectionList';
 import Text from '../Text';
 import styles from '../../styles/styles';
@@ -266,23 +267,20 @@ function BaseSelectionList({
         );
     };
 
-    /** Focuses the text input when the component mounts. If `props.shouldDelayFocus` is true, we wait for the animation to finish */
-    useEffect(() => {
-        if (shouldShowTextInput) {
-            if (shouldDelayFocus) {
+    /** Focuses the text input when the screen this component is included in comes into focus and any transitions to open that screen are completed. */
+    useFocusEffect(
+        useCallback(() => {
+            if (shouldShowTextInput) {
                 focusTimeoutRef.current = setTimeout(() => textInputRef.current.focus(), CONST.ANIMATED_TRANSITION);
-            } else {
-                textInputRef.current.focus();
-            }
-        }
-
-        return () => {
-            if (!focusTimeoutRef.current) {
-                return;
             }
-            clearTimeout(focusTimeoutRef.current);
-        };
-    }, [shouldDelayFocus, shouldShowTextInput]);
+            return () => {
+                if (!focusTimeoutRef.current) {
+                    return;
+                }
+                clearTimeout(focusTimeoutRef.current);
+            };
+        }, [shouldShowTextInput]),
+    );
 
     /** Selects row when pressing Enter */
     useKeyboardShortcut(CONST.KEYBOARD_SHORTCUTS.ENTER, selectFocusedOption, {

useFocusEffect runs whenever a card comes into focus, whether it was just pushed or the one on top was just popped, so that's great 👍🏼

The only downside (and it's pretty minor...) is that we're still using setTimeout, and that just feels a bit brittle. In reality it might be the best option though.

@roryabraham
Copy link
Contributor

Started a draft PR with this implementation: #25983

That said, I don't think this needs to be a deploy blocker. Demoting this.

@roryabraham roryabraham added Daily KSv2 and removed DeployBlockerCash This issue or pull request should block deployment Hourly KSv2 labels Aug 25, 2023
@thiagobrez
Copy link
Contributor

PR is ready to review here: #26415

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Sep 1, 2023
@roryabraham
Copy link
Contributor

PR is on staging

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Sep 14, 2023
@melvin-bot melvin-bot bot changed the title Web - Input field not focused on click of back button from Get assistance page [HOLD for payment 2023-09-21] Web - Input field not focused on click of back button from Get assistance page Sep 14, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 14, 2023

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

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Sep 14, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 14, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.69-2 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-09-21. 🎊

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 14, 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:

@kadiealexander
Copy link
Contributor

@roryabraham seems like no one is due payments based on this comment from you, can you please confirm if that's still correct?

@melvin-bot melvin-bot bot removed the Overdue label Sep 25, 2023
@roryabraham
Copy link
Contributor

Correct, no payments due. Going to close this out.

@gadhiyamanan
Copy link
Contributor

gadhiyamanan commented Sep 26, 2023

@roryabraham this is eligible for reporting bonus
cc: @kadiealexander

@roryabraham roryabraham reopened this Sep 26, 2023
@roryabraham
Copy link
Contributor

Sorry about that. Looks like reporting bonus should apply here

@kadiealexander
Copy link
Contributor

kadiealexander commented Sep 27, 2023

Sent you a contract @gadhiyamanan!

https://www.upwork.com/ab/applicants/1706896515002716160/hired for my own reference

@gadhiyamanan
Copy link
Contributor

@kadiealexander offer accepted, thanks!

@kadiealexander
Copy link
Contributor

Nice! All paid :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering
Projects
None yet
Development

No branches or pull requests

10 participants