-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
[Hotkeys] Hide hotkeys dialog on 'shift + ?' keypress #1301
Changes from 1 commit
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 |
---|---|---|
|
@@ -11,7 +11,7 @@ import { safeInvoke } from "../../common/utils"; | |
import { Hotkey, IHotkeyProps } from "./hotkey"; | ||
import { comboMatches, getKeyCombo, IKeyCombo, parseKeyCombo } from "./hotkeyParser"; | ||
import { IHotkeysProps } from "./hotkeys"; | ||
import { isHotkeysDialogShowing, showHotkeysDialog } from "./hotkeysDialog"; | ||
import { hideHotkeysDialogAfterDelay, isHotkeysDialogShowing, showHotkeysDialog } from "./hotkeysDialog"; | ||
|
||
const SHOW_DIALOG_KEY = "?"; | ||
|
||
|
@@ -53,14 +53,20 @@ export class HotkeysEvents { | |
} | ||
|
||
public handleKeyDown = (e: KeyboardEvent) => { | ||
if (this.isTextInput(e) || isHotkeysDialogShowing()) { | ||
if (this.isTextInput(e)) { | ||
return; | ||
} | ||
|
||
const combo = getKeyCombo(e); | ||
|
||
if (comboMatches(parseKeyCombo(SHOW_DIALOG_KEY), combo)) { | ||
showHotkeysDialog(this.actions.map((action) => action.props)); | ||
if (isHotkeysDialogShowing()) { | ||
hideHotkeysDialogAfterDelay(); | ||
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. why is the delay necessary here? what's wrong with simply 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. Because a bunch of disjoint hotkey Introducing a small delay is the only way to guarantee all those 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. Added a comment. |
||
} else { | ||
showHotkeysDialog(this.actions.map((action) => action.props)); | ||
} | ||
return; | ||
} else if (isHotkeysDialogShowing()) { | ||
return; | ||
} | ||
|
||
|
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.
feels more accurate to declare these as
number
rather than initialize to a likely invalid ID (althoughclearTimeout
happily ignores invalid IDs)