mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-24 13:29:55 +00:00
fixed hotkey race condition
This commit is contained in:
parent
79de7ec015
commit
434bacf185
@ -72,20 +72,21 @@ export class HotkeysService {
|
|||||||
@Inject(HotkeyProvider) private hotkeyProviders: HotkeyProvider[],
|
@Inject(HotkeyProvider) private hotkeyProviders: HotkeyProvider[],
|
||||||
hostApp: HostAppService,
|
hostApp: HostAppService,
|
||||||
) {
|
) {
|
||||||
const events = ['keydown', 'keyup']
|
|
||||||
events.forEach(eventType => {
|
|
||||||
document.addEventListener(eventType, (nativeEvent: KeyboardEvent) => {
|
|
||||||
this._keyEvent.next(nativeEvent)
|
|
||||||
this.pushKeyEvent(eventType, nativeEvent)
|
|
||||||
if (hostApp.platform === Platform.Web && this.matchActiveHotkey(true) !== null) {
|
|
||||||
nativeEvent.preventDefault()
|
|
||||||
nativeEvent.stopPropagation()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
this.config.ready$.toPromise().then(async () => {
|
this.config.ready$.toPromise().then(async () => {
|
||||||
const hotkeys = await this.getHotkeyDescriptions()
|
const hotkeys = await this.getHotkeyDescriptions()
|
||||||
this.hotkeyDescriptions = hotkeys
|
this.hotkeyDescriptions = hotkeys
|
||||||
|
const events = ['keydown', 'keyup']
|
||||||
|
|
||||||
|
events.forEach(eventType => {
|
||||||
|
document.addEventListener(eventType, (nativeEvent: KeyboardEvent) => {
|
||||||
|
this._keyEvent.next(nativeEvent)
|
||||||
|
this.pushKeyEvent(eventType, nativeEvent)
|
||||||
|
if (hostApp.platform === Platform.Web && this.matchActiveHotkey(true) !== null) {
|
||||||
|
nativeEvent.preventDefault()
|
||||||
|
nativeEvent.stopPropagation()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// deprecated
|
// deprecated
|
||||||
|
Loading…
x
Reference in New Issue
Block a user