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

[$1000] ESC key focuses the input field in emoji picker before closing it #18559

Closed
2 of 6 tasks
kavimuru opened this issue May 7, 2023 · 25 comments
Closed
2 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

@kavimuru
Copy link

kavimuru commented May 7, 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 emoji picker
  2. remove focus by clicking outside
  3. now press ESC

Expected results:

should close the emoji picker

Actual results:

re-focuses the search field before closing it

Workaround:

Can the user still use Expensify without this being fixed? Have you informed them of the workaround?

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.11.2
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

bandicam.2023-05-06.21-36-37-911.mp4
Recording.521.mp4

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

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01cd478505a855a06d
  • Upwork Job ID: 1655819951666835456
  • Last Price Increase: 2023-05-09
@kavimuru kavimuru added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels May 7, 2023
@melvin-bot
Copy link

melvin-bot bot commented May 7, 2023

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

@melvin-bot
Copy link

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

@huzaifa-99
Copy link
Contributor

huzaifa-99 commented May 8, 2023

Proposal

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

We want to prevent the search field getting focused in emoji picker when its already not focused and escape is pressed.

What is the root cause of that problem?

We are focusing the search input here as a default condition

if (this.searchInput && !this.searchInput.isFocused()) {
this.setState({selectTextOnFocus: false});
this.searchInput.focus();

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

We should prevent the input getting focused when escape is pressed (and its already not focused) by adding an additional condition keyBoardEvent.key !== 'Escape' here

if (this.searchInput && !this.searchInput.isFocused() && keyBoardEvent.key !== 'Escape') {
    this.setState({selectTextOnFocus: false});
    this.searchInput.focus();

    // Re-enable selection on the searchInput
    this.setState({selectTextOnFocus: true});
}

What alternative solutions did you explore? (Optional)

N/A

@dukenv0307
Copy link
Contributor

dukenv0307 commented May 8, 2023

Proposal

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

ESC key focuses the input field in emoji picker before closing it

What is the root cause of that problem?

We allow typing in the search box if any key is pressed. But we don't prevent some special keys like command, esc, option, control,...

// We allow typing in the search box if any key is pressed apart from Arrow keys.
if (this.searchInput && !this.searchInput.isFocused()) {
this.setState({selectTextOnFocus: false});
this.searchInput.focus();
// Re-enable selection on the searchInput
this.setState({selectTextOnFocus: true});
}
};

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

We should check if the pressed key is a special key (length > 1) or a key is pressed in combination with Meta, Control, Alt. we will prevent focusing the input like this



             if (this.searchInput.isFocused()) {
                this.setState({selectTextOnFocus: true});
                return;
            }
            // If the key pressed is non-character keys like Enter, Shift, ... do not focus
            if (keyBoardEvent.key.length > 1) {
                this.setState({selectTextOnFocus: false});
                return;
            }

            // If a key is pressed in combination with Meta, Control or Alt do not focus
            if ((keyBoardEvent.metaKey || keyBoardEvent.ctrlKey || keyBoardEvent.altKey)) {
                this.setState({selectTextOnFocus: false});
                return;
            }

            // We allow typing in the search box if any key is pressed apart from Arrow keys.
        
               if (this.searchInput) {
                this.setState({selectTextOnFocus: false});
                this.searchInput.focus();

                // Re-enable selection on the searchInput
                this.setState({selectTextOnFocus: true});
            }
        



What alternative solutions did you explore? (Optional)

@michaelhaxhiu michaelhaxhiu removed their assignment May 8, 2023
@michaelhaxhiu michaelhaxhiu added Bug Something is broken. Auto assigns a BugZero manager. and removed Bug Something is broken. Auto assigns a BugZero manager. labels May 8, 2023
@melvin-bot
Copy link

melvin-bot bot commented May 8, 2023

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

@michaelhaxhiu
Copy link
Contributor

Re-assigning because I'm headed OOO this week (starting this evening) and need to clear my plate.

@kadiealexander
Copy link
Contributor

Reproduced on the desktop web app:

2023-05-09_18-18-29.mp4

@Expensify Expensify deleted a comment from melvin-bot bot May 9, 2023
@kadiealexander kadiealexander added the External Added to denote the issue can be worked on by a contributor label May 9, 2023
@melvin-bot melvin-bot bot changed the title ESC key focuses the input field in emoji picker before closing it [$1000] ESC key focuses the input field in emoji picker before closing it May 9, 2023
@melvin-bot
Copy link

melvin-bot bot commented May 9, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented May 9, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented May 9, 2023

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

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

melvin-bot bot commented May 9, 2023

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

@dukenv0307
Copy link
Contributor

PROPOSAL

updated

@melvin-bot
Copy link

melvin-bot bot commented May 9, 2023

📣 @qsstudioprince! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:

  1. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  2. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  3. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
    Screen Shot 2022-11-16 at 4 42 54 PM
    Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

@qsstudioprince
Copy link

Contributor details
Your Expensify account email: [email protected]
Upwork Profile Link: https://www.upwork.com/freelancers/~014fb8412d7c83935a

@melvin-bot
Copy link

melvin-bot bot commented May 9, 2023

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

@qsstudioprince
Copy link

Proposal

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

Pressing the ESC key in the Emoji menu (when search bar is not focused) focuses the search bar before closing.

What is the root cause of that problem?

The final if statement in keyDownHandler, triggers the search input to focus as the if statement only checks if search input is not focused.

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

When the ESC key is pressed, it should simply execute the default behaviour and close the menu without having to execute any of the actions inside keyDownHandler.
We should add a if statement at the beginning of the handler to check if ESC is pressed and return from the function without executing any of the other if statements.
this.keyDownHandler = (keyBoardEvent) => { if (keyBoardEvent.key === 'Escape') { return; } .... }

What alternative solutions did you explore? (Optional)

I explored the other proposals mentioned above which works as well. However, I feel there is no need to go through all the if statements if ESC is pressed.

@thesahindia
Copy link
Member

I am not sure about the expected behaviour, so I will ask about it on Slack after completing other tasks.

@chiragxarora
Copy link
Contributor

chiragxarora commented May 9, 2023

I'm very sure this is introduced with a recent merge since at the time of reporting, it was only present in staging and not in production. I mentioned it in the bug report too but I think that was missed by the OP while creating issue.
original bug report

Can also be seen in the video attached in bug report by me

@thesahindia
Copy link
Member

I'm very sure this is introduced with a recent merge since at the time of reporting, it was only present in staging and not in production. I mentioned it in the bug report too but I think that was missed by the OP while creating issue. original bug report

Can also be seen in the video attached in bug report by me

Thanks for pointing that out! Before moving forward, we will have to find the PR that caused this (to prevent introducing any regressions)

@dukenv0307
Copy link
Contributor

@thesahindia This PR causes this bug.
Before: We always subscribe the ESC key to close modal
Screenshot 2023-05-12 at 22 19 46
So that, the modal is closed before the key down listener is triggered here

// We allow typing in the search box if any key is pressed apart from Arrow keys.
if (this.searchInput && !this.searchInput.isFocused()) {
this.setState({selectTextOnFocus: false});
this.searchInput.focus();
// Re-enable selection on the searchInput
this.setState({selectTextOnFocus: true});
}
};

--> this bug doesn't happen

Now: After This PR is merged, we only subscribe ESC key when this.props.isShortcutsModalOpen === true. So in this bug, the app doesn't subscribe ESC key and then this code is triggered before the modal closed

// We allow typing in the search box if any key is pressed apart from Arrow keys.
if (this.searchInput && !this.searchInput.isFocused()) {
this.setState({selectTextOnFocus: false});
this.searchInput.focus();
// Re-enable selection on the searchInput
this.setState({selectTextOnFocus: true});
}
};

@melvin-bot melvin-bot bot added the Overdue label May 12, 2023
@dukenv0307
Copy link
Contributor

So IMO, the RCA is we don't prevent subscribing the special key in the emoji search input (It's unnecessary)

In the main composer, we also don't focus if a key is pressed in combination with Meta, Control or Alt or If the key pressed is non-character keys like Enter, Shift (see this PR)

@techievivek
Copy link
Contributor

I am not sure if this is worth fixing because it seems to close the emoji picker just fine.

@melvin-bot melvin-bot bot removed the Overdue label May 12, 2023
@dukenv0307
Copy link
Contributor

dukenv0307 commented May 12, 2023

@techievivek Could you see my proposal? I think we still should prevent focus to search input when the user type Enter, Esc, Cmd, Shift Key,... or a key is pressed in combination with Meta, Control or Alt like in the main composer in this PR
cc @thesahindia

@chiragxarora
Copy link
Contributor

chiragxarora commented May 12, 2023

I am not sure if this is worth fixing because it seems to close the emoji picker just fine.

I'm not sure if this is the right reason to close the issue since its FOCUSING search composer when user intends to CLOSE the picker which is quite contradictory in itself. Also, that brief flash doesn't look user friendly at all and lastly, its a something we did not intend and is found in regression
cc @thesahindia

@dukenv0307
Copy link
Contributor

@techievivek I just created new bug on Slack to catch this bug

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

9 participants