-
-
Notifications
You must be signed in to change notification settings - Fork 348
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
check if in popup before triggering shortcut #2789
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -51,7 +51,8 @@ export class KeybinderService { | |||||||
this.store.dispatch( | ||||||||
new dialogsActions.ToggleVariableDialogAction(this.activeWindowId) | ||||||||
), | ||||||||
'Toggle Variable Pane' | ||||||||
'Toggle Variable Pane', | ||||||||
true | ||||||||
); | ||||||||
|
||||||||
this.bindShortcut( | ||||||||
|
@@ -60,16 +61,15 @@ export class KeybinderService { | |||||||
this.store.dispatch( | ||||||||
new dialogsActions.ToggleHeaderDialogAction(this.activeWindowId) | ||||||||
), | ||||||||
'Toggle Header Pane' | ||||||||
'Toggle Header Pane', | ||||||||
true | ||||||||
); | ||||||||
|
||||||||
this.bindShortcut( | ||||||||
['Ctrl+Shift+R'], | ||||||||
() => | ||||||||
this.store.dispatch( | ||||||||
new queryActions.SendIntrospectionQueryRequestAction( | ||||||||
this.activeWindowId | ||||||||
) | ||||||||
new queryActions.SendIntrospectionQueryRequestAction(this.activeWindowId) | ||||||||
), | ||||||||
'Reload Docs' | ||||||||
); | ||||||||
|
@@ -87,9 +87,7 @@ export class KeybinderService { | |||||||
['Ctrl+Shift+P'], | ||||||||
() => { | ||||||||
if ( | ||||||||
document.activeElement?.closest( | ||||||||
VARIABLE_EDITOR_COMPONENT_ELEMENT_NAME | ||||||||
) | ||||||||
document.activeElement?.closest(VARIABLE_EDITOR_COMPONENT_ELEMENT_NAME) | ||||||||
) { | ||||||||
this.store.dispatch( | ||||||||
new variablesActions.PrettifyVariablesAction(this.activeWindowId) | ||||||||
|
@@ -156,7 +154,8 @@ export class KeybinderService { | |||||||
bindShortcut( | ||||||||
keys: string[], | ||||||||
callback: (...args: unknown[]) => unknown, | ||||||||
description = 'TODO - Add description' | ||||||||
description: string, | ||||||||
allowInPopups = false | ||||||||
Comment on lines
+157
to
+158
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||||
) { | ||||||||
this.shortcuts.push({ | ||||||||
keys, | ||||||||
|
@@ -166,6 +165,9 @@ export class KeybinderService { | |||||||
return (mousetrap as any).bindGlobal( | ||||||||
keys.map((key) => key.toLowerCase()), | ||||||||
() => { | ||||||||
if (!allowInPopups && this.isInPopup()) { | ||||||||
return; | ||||||||
} | ||||||||
this.zone.run(callback); | ||||||||
return false; | ||||||||
} | ||||||||
|
@@ -209,4 +211,9 @@ export class KeybinderService { | |||||||
|
||||||||
return categories; | ||||||||
} | ||||||||
|
||||||||
private isInPopup() { | ||||||||
const activeElement = document.activeElement as HTMLElement | null; | ||||||||
return !!activeElement?.closest('nz-modal-container'); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function relies on the presence of
Suggested change
|
||||||||
} | ||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrapping the content in a
<form>
element might interfere with existing form elements within the dialog content. Consider if this is the best approach, or if there's a way to prevent potential conflicts. For example, could you add a class to the form and target that class in your CSS to avoid style conflicts?