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

fix: prevent page hotkeys firing with opened YTDialog [#768] #992

Merged
merged 5 commits into from
Feb 12, 2025

Conversation

vrozaev
Copy link
Collaborator

@vrozaev vrozaev commented Feb 12, 2025

Issue: #768

The rootcase of the issue is a way of hotkeys declaration via hotkeys-js.

Each hotkey is declared in some scope. Now that scope stays the same when any modal windows opens. That means that hotkeys from the page could be triggered with opened modal window, which might lead to unforeseen results.

The obvious solution here is switching hotkeys scope once any modal window become visible. That prevent page hotkeys from firing.

So we need to modify all code which shows any king of modal windows and add there a scope switch.

  1. packages/ui/src/ui/components/Dialog/Dialog.tsx
  2. packages/ui/src/ui/components/Modal/Modal.tsx
  3. packages/ui/src/ui/components/Modal/SimpleModal.tsx

Also, there are a lot of direct usage of Dialog and Modal components from @gravity-ui/uikit. I think we need to introduce wrappers for them and switch scope there. Let's name them YTDialog and YTModal.

@vrozaev vrozaev force-pushed the vrozaev/fix-hotkeys-firing-within-dialog-768 branch from 5c8eaac to 229668b Compare February 12, 2025 12:44
@vrozaev vrozaev force-pushed the vrozaev/fix-hotkeys-firing-within-dialog-768 branch from 229668b to 767fd74 Compare February 12, 2025 12:49
"paths": [
{
"name": "@gravity-ui/uikit",
"importNames": ["Dialog"],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"name": "@gravity-ui/dialog-fields",
"importNames": ["DFDialog"],

And // eslint-disable-next-line no-restricted-imports should be also present for the rule

@vrozaev vrozaev force-pushed the vrozaev/fix-hotkeys-firing-within-dialog-768 branch from 767fd74 to b05f848 Compare February 12, 2025 13:00
@vrozaev vrozaev force-pushed the vrozaev/fix-hotkeys-firing-within-dialog-768 branch from b05f848 to d89a48a Compare February 12, 2025 13:03
@vrozaev vrozaev force-pushed the vrozaev/fix-hotkeys-firing-within-dialog-768 branch from b17ee79 to 819d704 Compare February 12, 2025 13:47
@vrozaev vrozaev merged commit 337c349 into main Feb 12, 2025
10 checks passed
@vrozaev vrozaev deleted the vrozaev/fix-hotkeys-firing-within-dialog-768 branch February 12, 2025 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants