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 2021-11-04] Pressing Escape on the confirmation modal while removing a Member closes both modals - @parasharrajat #5769

Closed
isagoico opened this issue Oct 12, 2021 · 16 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production External Added to denote the issue can be worked on by a contributor Weekly KSv2

Comments

@isagoico
Copy link

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

  1. Navigate to Workspace settings
  2. Navigate to members
  3. Check one from the list and click on remove
  4. Once the remove modal appears, press the esc button

Expected Result:

Only the remove modal should be dismissed

Actual Result:

Both the remove modal and the right panel are dismissed

Workaround:

Don't press the escape button in the modal.

Platform:

Where is this issue occurring?

  • Web
  • Desktop App

Version Number: 1.1.7-3

Reproducible in staging?: Yes
Reproducible in production?: Yes

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

Notes/Photos/Videos: Any additional supporting documentation

Recording.224.mp4

Expensify/Expensify Issue URL:

Issue reported by: @parasharrajat
Slack conversation: https://expensify.slack.com/archives/C01GTK53T8Q/p1633962922114200

View all open jobs on GitHub

@MelvinBot
Copy link

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

@isagoico isagoico changed the title Pressing Escape on the confirmation modal while removing the Member closes both modals - @parasharrajat Pressing Escape on the confirmation modal while removing a Member closes both modals - @parasharrajat Oct 12, 2021
@parasharrajat
Copy link
Member

Proposal

I tried many ways to intercept the Escape key but Modal onBackButtonPress which handles the escape key does not pass the event to the callback.

// Note: Escape key on web/desktop will trigger onBackButtonPress callback
// eslint-disable-next-line react/jsx-props-no-multi-spaces
onBackButtonPress={this.props.onClose}

So the best solution so far is to Block the close of a page when Modal is shown over the screen. which should be the case. For example, on any screen if a user has done some action and a confirmation modal is shown then escape key should only interact with that Modal not other parts of the app.

Solution

  1. We will block the screen dismiss at
    Navigation.dismissModal();
 this.unsubscribeEscapeKey = KeyboardShortcut.subscribe('Escape', () => {
            if (!this.props.modal.isVisible) {
                Navigation.dismissModal();
            }
        }, [], true);
  1. Modal visibility can be taken from Onyx.
 withOnyx({
        modal: {
            key: ONYXKEYS.MODAL,
        },
    }),

@cead22 cead22 added Weekly KSv2 and removed Daily KSv2 labels Oct 14, 2021
@cead22 cead22 removed their assignment Oct 14, 2021
@cead22 cead22 added Daily KSv2 External Added to denote the issue can be worked on by a contributor and removed Weekly KSv2 labels Oct 14, 2021
@MelvinBot
Copy link

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

@kadiealexander
Copy link
Contributor

@MelvinBot MelvinBot added Weekly KSv2 Help Wanted Apply this label when an issue is open to proposals by contributors and removed Daily KSv2 labels Oct 14, 2021
@MelvinBot
Copy link

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

@thorep
Copy link

thorep commented Oct 14, 2021

I dont know what css framework you are using, but a lot of them don’t allow stacked modals. Workaround is to wrap the modals and disable keyboard input, input will then be handled individually by the modals. Don’t have an up work account I’m afraid :/

@ThadeusAjayi
Copy link

Proposed Fix:

Have a ref for each of the modals to track the active/topmost modal, listen to keyboard event on the escape key and dismiss modal based on the most recent modal ref.

@Julesssss
Copy link
Contributor

Thanks for the proposals!

I prefer @parasharrajat's solution, as it's simpler and more self-contained than tracking recent modal state. Would you like to go ahead with this?


This is out of scope for now, but it made me wonder if it would be worthwhile to give all pages/Modals the ability to be lifecycle aware. Having callbacks for becoming active (top-level) and inactive (when another Modal/Page is opened on top) would allow us to be subscribed to the Escape key ONLY when it should be closable.

@MelvinBot MelvinBot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 15, 2021
@parasharrajat
Copy link
Member

So.

  1. When this code is merged, Modal Screens will not close until all the modals over are closed. and Modals are always top-level when Modal Screen is active.
  2. If we have multiple modals over the screen, then the Escape key will close the top-level only and thus close all one by one on each keypress.

it means we don't need to handle anything for now. @Julesssss

@kadiealexander
Copy link
Contributor

Deployed to staging, waiting for production deployment. Begone, Melvin.

@MelvinBot MelvinBot removed the Overdue label Oct 26, 2021
@botify botify added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Oct 28, 2021
@botify botify changed the title Pressing Escape on the confirmation modal while removing a Member closes both modals - @parasharrajat [HOLD for payment 2021-11-04] Pressing Escape on the confirmation modal while removing a Member closes both modals - @parasharrajat Oct 28, 2021
@botify
Copy link

botify commented Oct 28, 2021

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.1.10-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 2021-11-04. 🎊

@kadiealexander
Copy link
Contributor

kadiealexander commented Nov 5, 2021

@parasharrajat sorry I hadn't sent the Upwork hire! Please let me know when this is accepted and I'll pay it out asap. :)

@parasharrajat
Copy link
Member

@kadiealexander Done.

@parasharrajat
Copy link
Member

Ping for
image

@mallenexpensify
Copy link
Contributor

Paid @parasharrajat , inc. reporting and n6-hold bonus

@kadiealexander
Copy link
Contributor

Thanks for grabbing this on my weekend @mallenexpensify!!

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

No branches or pull requests

10 participants