[MM-40603] Add timeout for alt press to make sure it doesn't interfere with OS shortcuts (#1932)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
This commit is contained in:
@@ -61,6 +61,7 @@ export class MattermostView extends EventEmitter {
|
|||||||
|
|
||||||
currentFavicon?: string;
|
currentFavicon?: string;
|
||||||
hasBeenShown: boolean;
|
hasBeenShown: boolean;
|
||||||
|
altTimeout?: number;
|
||||||
altLastPressed?: boolean;
|
altLastPressed?: boolean;
|
||||||
contextMenu: ContextMenu;
|
contextMenu: ContextMenu;
|
||||||
|
|
||||||
@@ -285,6 +286,7 @@ export class MattermostView extends EventEmitter {
|
|||||||
// Handler for pressing the Alt key to focus the 3-dot menu
|
// Handler for pressing the Alt key to focus the 3-dot menu
|
||||||
if (input.key === 'Alt' && input.type === 'keyUp' && this.altLastPressed) {
|
if (input.key === 'Alt' && input.type === 'keyUp' && this.altLastPressed) {
|
||||||
this.altLastPressed = false;
|
this.altLastPressed = false;
|
||||||
|
clearTimeout(this.altTimeout);
|
||||||
WindowManager.focusThreeDotMenu();
|
WindowManager.focusThreeDotMenu();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -292,8 +294,12 @@ export class MattermostView extends EventEmitter {
|
|||||||
// Hack to detect keyPress so that alt+<key> combinations don't default back to the 3-dot menu
|
// 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') {
|
if (input.key === 'Alt' && input.type === 'keyDown') {
|
||||||
this.altLastPressed = true;
|
this.altLastPressed = true;
|
||||||
|
this.altTimeout = setTimeout(() => {
|
||||||
|
this.altLastPressed = false;
|
||||||
|
}, 500) as unknown as number;
|
||||||
} else {
|
} else {
|
||||||
this.altLastPressed = false;
|
this.altLastPressed = false;
|
||||||
|
clearTimeout(this.altTimeout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user