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

[$500] Web - Private Note - Input is not focused after reloading the page. #27695

Closed
1 of 6 tasks
kbecciv opened this issue Sep 18, 2023 · 21 comments
Closed
1 of 6 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@kbecciv
Copy link

kbecciv commented Sep 18, 2023

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 any Report => Report Details => Private Notes.
  2. Click My Notes => Reload the page.
  3. Notice that the Input is not focused.

Expected Result:

Input should be focused after reloading the page.

Actual Result:

Input is not focused after reloading the 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: 1.3.71.4
Reproducible in staging?: y
Reproducible in production?: new feature
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-17.at.11.27.44.mov
Recording.4575.mp4

Expensify/Expensify Issue URL:
Issue reported by: @hungvu193
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1694924854779879

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~012866eed98442daeb
  • Upwork Job ID: 1703807251460964352
  • Last Price Increase: 2023-10-02
@kbecciv kbecciv added the External Added to denote the issue can be worked on by a contributor label Sep 18, 2023
@dukenv0307
Copy link
Contributor

Proposal

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

Dev: Web - Private notes - Delay in displaying the "Notes" field and "Save" button when refreshing the Private

What is the root cause of that problem?

We focus the input when the onEntryTransitionEnd is triggered. But when we reload the page, sometimes this is not triggered.

onEntryTransitionEnd={() => focusAndUpdateMultilineInputRange(privateNotesInput.current)}

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

We should use useFocusEffect and InteractionManager.runAfterInteractions in the same way we operate in EditRequestAmountPage to make the input is always focused when the page is focused.

useFocusEffect(
    useCallback(() => {
        InteractionManager.runAfterInteractions(() => {
            focusAndUpdateMultilineInputRange(privateNotesInput.current);
        })
    }, []),
);

What alternative solutions did you explore? (Optional)

NA

Result

Screencast.from.17-09-2023.21.17.33.webm

@kbecciv kbecciv added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Sep 18, 2023
@melvin-bot
Copy link

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 18, 2023

Job added to Upwork: https://www.upwork.com/jobs/~012866eed98442daeb

@melvin-bot melvin-bot bot changed the title Web - Private Note - Input is not focused after reloading the page. [$500] Web - Private Note - Input is not focused after reloading the page. Sep 18, 2023
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 18, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 18, 2023

Triggered auto assignment to @jliexpensify (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

@melvin-bot
Copy link

melvin-bot bot commented Sep 18, 2023

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

@kbecciv
Copy link
Author

kbecciv commented Sep 18, 2023

Proposal by: @hungvu193
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1694924854779879

Proposal

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

Private Note - Input is not focused after reloading the page.

What is the root cause of that problem?

We're focusing the input after transition end, however while the page is reloading, privateNotesInput.current will be null first focusAndUpdateMultilineInputRange will early return.

onEntryTransitionEnd={() => focusAndUpdateMultilineInputRange(privateNotesInput.current)}

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

Incase privateNotesInput is set yet and screen did end transition, we should focus the Input. So we should update the TextInput's ref as below:

    ref={(el) => {
        if (!el) {
            return;
        }
        if (!privateNotesInput.current && didScreenTransitionEnd) {
            focusAndUpdateMultilineInputRange(el);
        }
        privateNotesInput.current = el;
    }}

What alternative solutions did you explore? (Optional)

N/A

@ZhenjaHorbach
Copy link
Contributor

ZhenjaHorbach commented Sep 18, 2023

Proposal

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

Input does not focus after reloading the page.

What is the root cause of that problem?

onEntryTransitionEnd and focusAndUpdateMultilineInputRange doesn't work correctly after reloading the page.

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

We can add autoFocus for this input

<TextInput
accessibilityRole={CONST.ACCESSIBILITY_ROLE.TEXT}
inputID="privateNotes"
label={translate('privateNotes.composerLabel')}
accessibilityLabel={translate('privateNotes.title')}
autoCompleteType="off"
autoCorrect={false}
autoGrowHeight
textAlignVertical="top"
containerStyles={[styles.autoGrowHeightMultilineInput]}
defaultValue={privateNote}
value={privateNote}
onChangeText={(text) => setPrivateNote(text)}
ref={(el) => (privateNotesInput.current = el)}
/>

Screen.Recording.2023-09-18.at.18.34.23.mov

What alternative solutions did you explore? (Optional)

NA

@jayeshmangwani
Copy link
Contributor

Proposal

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

Private Note - Input is not focused after reloading the page.

What is the root cause of that problem?

Currently we use onEntryTransitionEnd on Edit Note Page

onEntryTransitionEnd={() => focusAndUpdateMultilineInputRange(privateNotesInput.current)}

Sometimes input ref is not yet set on the page load and then we get null ref here, So that input will be null and focus does not call and it returns early

if (!input) {
return;
}
input.focus();

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

We should follow this new approach for setting the focus on a load of the page, using the setTimeout and we should remove onEntryTransitionEnd call

instead need to add this code on the PrivateNotesEditPage page

const focusTimeoutRef = useRef(null);

useFocusEffect(useCallback(() => {
    focusTimeoutRef.current = setTimeout(()=> focusAndUpdateMultilineInputRange(privateNotesInput.current), CONST.ANIMATED_TRANSITION);
    return () => {
        if (!focusTimeoutRef.current) {
            return;
        }
        clearTimeout(focusTimeoutRef.current);
    };
}, []));
Result
refresh-edit-page.mov

What alternative solutions did you explore? (Optional)

none

@b4s36t4
Copy link
Contributor

b4s36t4 commented Sep 18, 2023

Proposal

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

Web - Private Note - Input is not focused after reloading the page.

What is the root cause of that problem?

We had several issues like this which are raised because of the onEntryTransitionEnd is not firing because of onyx updates and everything.

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

Since we changed our way of handling animations, so we should follow the same approach.

We need to handle the focus for TextInput inside BaseTextInput the way we handle in BaseSelectionList

pseudo code:

useFocusEffect(
    useCallback(() => {
        if (!props.autoFocus || !input.current) return;

        let focusTimeout;
        if (props.shouldDelayFocus) {
            focusTimeout = setTimeout(() => input.current.focus(), CONST.ANIMATED_TRANSITION);
            return;
        }
        input.current.focus();

        return () => {
            if (!focusTimeout) {
                return;
            }
            clearTimeout(focusTimeout);
        };
    }, [props, input]),
);

What alternative solutions did you explore? (Optional)

NA

@jliexpensify jliexpensify removed their assignment Sep 18, 2023
@jliexpensify
Copy link
Contributor

Unassigning myself as Kadie was the first assigned B0 member.

@jeet-dhandha
Copy link
Contributor

jeet-dhandha commented Sep 18, 2023

Proposal

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

  • TextInput not focusing on reloading the page.

What is the root cause of that problem?

  • Issue is whenever we wrap TextInput inside FullPageNotFoundView it's not focusing on reloading the page.

// if we wrap the page with FullPageNotFoundView we need to explicitly handle focusing on text input

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

  • We need to handle focus on PrivateNotesEditPage just like below ReportWelcomeMessagePage.js.
  • This will fix the cursor position as well. (which autoFocus will not be able to fix.)

onEntryTransitionEnd={() => {
if (!welcomeMessageInputRef.current) {
return;
}
focusAndUpdateMultilineInputRange(welcomeMessageInputRef.current);
}}

{({didScreenTransitionEnd}) => (

ref={(el) => {
// Before updating the DOM, React sets the affected ref.current values to null. After updating the DOM, React immediately sets them to the corresponding DOM nodes
// to avoid focus multiple time, we should early return if el is null.
if (!el) {
return;
}
if (!welcomeMessageInputRef.current && didScreenTransitionEnd) {
focusAndUpdateMultilineInputRange(el);
}
welcomeMessageInputRef.current = el;
}}

What alternative solutions did you explore? (Optional)

  • N/A

@melvin-bot melvin-bot bot added the Overdue label Sep 21, 2023
@kadiealexander
Copy link
Contributor

@Ollyws could you please take a look at the proposals above?

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Sep 22, 2023
@kadiealexander
Copy link
Contributor

Bumped in Slack!

@Ollyws
Copy link
Contributor

Ollyws commented Sep 25, 2023

Seems like this was already fixed by #27702

@hungvu193
Copy link
Contributor

Agree. I couldn't reproduce as well

@melvin-bot
Copy link

melvin-bot bot commented Sep 25, 2023

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@Ollyws
Copy link
Contributor

Ollyws commented Sep 27, 2023

@kadiealexander We're good to close this one as it's already been fixed, thanks.

@melvin-bot melvin-bot bot added the Overdue label Oct 2, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 2, 2023

@Ollyws @kadiealexander this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

@melvin-bot
Copy link

melvin-bot bot commented Oct 2, 2023

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@melvin-bot
Copy link

melvin-bot bot commented Oct 3, 2023

@Ollyws, @kadiealexander 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
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
None yet
Development

No branches or pull requests

10 participants