mirror of
https://github.com/Eugeny/tabby.git
synced 2024-12-09 06:20:22 +08: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[],
|
||||
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 () => {
|
||||
const hotkeys = await this.getHotkeyDescriptions()
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user