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-10-23] [HOLD for payment 2023-10-23] [$500] Web - Chat - Edit message box blink on escape from keyboard shortcut popup #26527

Closed
1 of 6 tasks
izarutskaya opened this issue Sep 1, 2023 · 68 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 External Added to denote the issue can be worked on by a contributor

Comments

@izarutskaya
Copy link

izarutskaya commented Sep 1, 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. Open the app
  2. Open any report
  3. Edit any message
  4. Click CTRL+J to open keyboard shortcut
  5. Click ESC to close popup and observe that edit message box blinks before changing focus to main compose box

Expected Result:

Edit message box should not glitch out on change of focus to main compose box as it works currently on ESC from CTRL+K or CTRL+SHIFT+K shortcuts

Actual Result:

Edit message box blinks on change of focus to main compose box when keyboard shortcut is open using CTRL+J and closed by ESC

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.61-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): Y

Logs: https://stackoverflow.com/c/expensify/questions/4856

Notes/Photos/Videos: Any additional supporting documentation

edit.box.blink.on.ESC.mp4
Bandicam.2023-09-01.23-37-36-100.mp4

Expensify/Expensify Issue URL:

Issue reported by: @dhanashree-sawant

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

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01ad8834baac53effd
  • Upwork Job ID: 1698788846930915328
  • Last Price Increase: 2023-09-18
  • Automatic offers:
    • Dhanashree-Sawant | Reporter | 27049742
@izarutskaya izarutskaya added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Sep 1, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 1, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 1, 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 melvin-bot bot added the Overdue label Sep 4, 2023
@anmurali
Copy link

anmurali commented Sep 4, 2023

Can reproduce and is not a dupe

@melvin-bot melvin-bot bot removed the Overdue label Sep 4, 2023
@anmurali anmurali added the External Added to denote the issue can be worked on by a contributor label Sep 4, 2023
@melvin-bot melvin-bot bot changed the title Web - Chat - Edit message box blink on escape from keyboard shortcut popup [$500] Web - Chat - Edit message box blink on escape from keyboard shortcut popup Sep 4, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 4, 2023

Job added to Upwork: https://www.upwork.com/jobs/~01ad8834baac53effd

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 4, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 4, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 4, 2023

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

@joh42
Copy link
Contributor

joh42 commented Sep 5, 2023

What is the expected behavior here @anmurali? Should the edit message box be focused?

@ayazalavi

This comment was marked as outdated.

@narefyev91
Copy link
Contributor

Proposal

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

After selecting any chat from the sidebar and editing any comment within it, the focus shifts to the main compose input once you close the modal.

What is the root cause of that problem?

Problem exists in code where we are programmatically setting focus to the main composer. It happens in following code Screenshot 2023-09-06 at 2 49 21 PM File is ComposerWithSuggestions

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

commenting focus() in Line 433 solves the problem without breaking the code.

What alternative solutions did you explore? (Optional)

Rewrite focus handler for all inputs in order to manage it within a hook

Hey @ayazalavi ! Removing focus will fully break this logic:
// We want to focus or refocus the input when a modal has been closed or the underlying screen is refocused.

@ayazalavi
Copy link
Contributor

ayazalavi commented Sep 6, 2023

Hey @ayazalavi ! Removing focus will fully break this logic: // We want to focus or refocus the input when a modal has been closed or the underlying screen is refocused.

@narefyev91 Working video:

480.Screen.Recording.2023-09-06.at.5.13.08.PM.mov

It is not not breaking this "We want to focus or refocus the input when a modal has been closed or the underlying screen is refocused." Which modal is this referring to?

@narefyev91
Copy link
Contributor

@ayazalavi your fix will break all modal closing re-focus input logic:
With your fix:

Screen.Recording.2023-09-06.at.15.23.36.mov

Without your fix:

Screen.Recording.2023-09-06.at.15.24.23.mov

@ayazalavi
Copy link
Contributor

ayazalavi commented Sep 6, 2023

Proposal

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

After selecting any chat from the sidebar and editing any comment within it, the focus shifts to the main compose input once you close the modal with the glitch.

What is the root cause of that problem?

Root cause is the modal we are using in our codebase. It shifts focus back to input field as soon as it closes. reactjs/react-modal#680

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

Use ONYX to tap edit field focus. In

const ONYXKEYS = {

add EDITFOCUSED: 'editFocused',

Add

withOnyx({
        modal: {
            key: ONYXKEYS.MODAL,
        },
        editFocused: {
            key: ONYXKEYS.EDITFOCUSED
        }
    })

in

export default compose(
withLocalize,
withReportActionsDrafts({
propName: 'drafts',
}),
)(
React.forwardRef((props, ref) => (
<ReportActionItemMessageEdit
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
forwardedRef={ref}
/>
)),
);

and this

useEffect(() => {
        if (isFocused && !props.editFocused) {
            Onyx.set(ONYXKEYS.EDITFOCUSED, true);
            textInputRef.current.focus();
        }
        else if (!isFocused && props.editFocused && !props.modal.isVisible) {
            if (timeoutHandle) {
                clearTimeout(timeoutHandle)
                timeoutHandle = undefined
            }
            timeoutHandle = setTimeout(() => {
                if (!props.modal.isVisible && !props.modal.willAlertModalBecomeVisible) {
                    Onyx.set(ONYXKEYS.EDITFOCUSED, false);
                }
            }, 100)
        }
    }, [isFocused, props.editFocused, props.modal])

in

function ReportActionItemMessageEdit(props) {

The above useEffect ensures that if the edit input is focused, then ONYX EDITFOCUSED should be set to true. In the second condition, it checks if the input is not focused but was previously focused. In this case, it checks if the modal becomes visible using a timeout. If it doesn't become visible, then it sets ONYX EDITFOCUSED to false. This ensures that the input is only considered out of focus when it happens for reasons other than the modal.

The above code will work generically for all modals. It can be made more generic to ensure input field can maintain focus with modal opening and will prevent shifting focus to main composer input field. We can make it a hook as well to ensure field focus doesn't gets broken due to modal.

Here

export default compose(
withKeyboardState,
withOnyx({
numberOfLines: {
key: ({reportID}) => `${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT_NUMBER_OF_LINES}${reportID}`,
// We might not have number of lines in onyx yet, for which the composer would be rendered as null
// during the first render, which we want to avoid:
initWithStoredValues: false,
},

Add

editFocused: {
            key: ONYXKEYS.EDITFOCUSED
        },

Update this

focus();
}, [focus, prevIsFocused, prevIsModalVisible, isFocused, modal.isVisible, isNextModalWillOpenRef]);

to

 if (editFocused) {
            Onyx.set(ONYXKEYS.EDITFOCUSED, false);
            return;
        }
        focus();
    }, [focus, prevIsFocused, editFocused, prevIsModalVisible, isFocused, modal.isVisible, isNextModalWillOpenRef]);
 

add editFocused in props

Result:

Untitled.11.mp4

What alternative solutions did you explore? (Optional)

before opening modal blur edit text field.

@narefyev91
Copy link
Contributor

@ayazalavi can you please explain why those lines of code will fix issues - and did you test your code? Will it introduce any regression? Just the same as i mentioned above with focusing composer - after closing right panel

@ayazalavi
Copy link
Contributor

ayazalavi commented Sep 7, 2023

@narefyev91 please take a look at my new proposal here

#26527 (comment)

@melvin-bot melvin-bot bot added the Overdue label Sep 9, 2023
@narefyev91
Copy link
Contributor

@ayazalavi thank you for your updated proposal - but your code still introduce regressions
Example - how it should be:

Screen.Recording.2023-09-11.at.12.03.55.mov

How it's after your code:

Screen.Recording.2023-09-11.at.12.06.05.mov

@melvin-bot melvin-bot bot removed the Overdue label Sep 11, 2023
@narefyev91
Copy link
Contributor

Also some issues with Android web as well
Before:

Screen.Recording.2023-09-11.at.12.16.12.mov

After:

Screen.Recording.2023-09-11.at.12.13.51.mov

We should be sure that any new changes regarding autofocus will not introduce any regression on each platform

@ayazalavi
Copy link
Contributor

@narefyev91 thanks for such detailed review. Let me fix my proposal. Thanks again for the feedback as well.

@melvin-bot
Copy link

melvin-bot bot commented Sep 11, 2023

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

@ayazalavi
Copy link
Contributor

ayazalavi commented Sep 12, 2023

@narefyev91 update to #26527 (comment) proposal:

Root cause:

As soon as modal gets closed then this react hook gets called forcing focus to compose field:

useEffect(() => {
if (modal.isVisible && !prevIsModalVisible) {
// eslint-disable-next-line no-param-reassign
isNextModalWillOpenRef.current = false;
}
// We want to focus or refocus the input when a modal has been closed or the underlying screen is refocused.
// We avoid doing this on native platforms since the software keyboard popping
// open creates a jarring and broken UX.
if (!(willBlurTextInputOnTapOutside && !isNextModalWillOpenRef.current && !modal.isVisible && isFocused && (prevIsModalVisible || !prevIsFocused))) {
return;
}
focus();
}, [focus, prevIsFocused, prevIsModalVisible, isFocused, modal.isVisible, isNextModalWillOpenRef]);

Solution

Remove modal.isVisible from dependency array so that callback does'nt gets triggered on every modal closing.

}, [focus, prevIsFocused, prevIsModalVisible, isFocused, modal.isVisible, isNextModalWillOpenRef]);

Here is how it looks:

Untitled.mp4

@melvin-bot
Copy link

melvin-bot bot commented Oct 13, 2023

Based on my calculations, the pull request did not get merged within 3 working days of assignment. Please, check out my computations here:

  • when @ayazalavi got assigned: 2023-10-06 02:34:44 Z
  • when the PR got merged: 2023-10-13 13:32:55 UTC
  • days elapsed: 5

On to the next one 🚀

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Oct 16, 2023
@melvin-bot melvin-bot bot changed the title [$500] Web - Chat - Edit message box blink on escape from keyboard shortcut popup [HOLD for payment 2023-10-23] [$500] Web - Chat - Edit message box blink on escape from keyboard shortcut popup Oct 16, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Oct 16, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 16, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Oct 16, 2023

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

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 Oct 16, 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:

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

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Weekly KSv2 labels Oct 16, 2023
@melvin-bot melvin-bot bot changed the title [HOLD for payment 2023-10-23] [$500] Web - Chat - Edit message box blink on escape from keyboard shortcut popup [HOLD for payment 2023-10-23] [HOLD for payment 2023-10-23] [$500] Web - Chat - Edit message box blink on escape from keyboard shortcut popup Oct 16, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 16, 2023

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

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 Oct 16, 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:

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

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 Daily KSv2 labels Oct 23, 2023
@amyevans
Copy link
Contributor

@narefyev91 could you complete the checklist please?

@melvin-bot melvin-bot bot removed the Overdue label Oct 25, 2023
@narefyev91
Copy link
Contributor

  • The PR that introduced the bug has been identified. Link to the PR - fully new implementation - not coming from any regression
  • 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 - N/A
  • 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 - N/A
  • Determine if we should create a regression test for this bug - N/A

@ayazalavi
Copy link
Contributor

@flaviadefaria
Copy link
Contributor

Payment Summary:

@ayazalavi requires payment
@narefyev91 does not require payment (Contractor)
@dhanashree-sawant requires payment offer (Reporter)

@dhanashree-sawant = $50
@ayazalavi = $500 no bonus = $500

@flaviadefaria
Copy link
Contributor

@dhanashree-sawant = paid
@ayazalavi = offer sent

@flaviadefaria
Copy link
Contributor

Everyone has been paid so closing this.

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 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

7 participants