[MM-40603] Add timeout for alt press to make sure it doesn't interfere with OS shortcuts (#1932) (#1940)

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
(cherry picked from commit 8474683ff1)

Co-authored-by: Devin Binnie <52460000+devinbinnie@users.noreply.github.com>
This commit is contained in:
Mattermost Build 2022-01-04 16:56:01 +02:00 committed by GitHub
parent 99183613af
commit 36bc2a4e31
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -61,6 +61,7 @@ export class MattermostView extends EventEmitter {
currentFavicon?: string;
hasBeenShown: boolean;
altTimeout?: number;
altLastPressed?: boolean;
contextMenu: ContextMenu;
@ -293,6 +294,7 @@ export class MattermostView extends EventEmitter {
// Handler for pressing the Alt key to focus the 3-dot menu
if (input.key === 'Alt' && input.type === 'keyUp' && this.altLastPressed) {
this.altLastPressed = false;
clearTimeout(this.altTimeout);
WindowManager.focusThreeDotMenu();
return;
}
@ -300,8 +302,12 @@ export class MattermostView extends EventEmitter {
// Hack to detect keyPress so that alt+<key> combinations don't default back to the 3-dot menu
if (input.key === 'Alt' && input.type === 'keyDown') {
this.altLastPressed = true;
this.altTimeout = setTimeout(() => {
this.altLastPressed = false;
}, 500) as unknown as number;
} else {
this.altLastPressed = false;
clearTimeout(this.altTimeout);
}
}