Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 34 additions & 42 deletions ts/services/addGlobalKeyboardShortcuts.preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,50 +217,42 @@ export function addGlobalKeyboardShortcuts(): void {
// Preferences - handled by Electron-managed keyboard shortcuts

// Open the top-right menu for current conversation
if (
conversation &&
commandOrCtrl &&
shiftKey &&
(key === 'l' || key === 'L')
) {
const button = document.querySelector(
'.module-ConversationHeader__button--more'
);
if (!button) {
return;
}

if (
conversation &&
commandOrCtrl &&
shiftKey &&
(key === 'l' || key === 'L')
) {
const button = document.querySelector(
'.module-ConversationHeader__button--more'
);
if (!button) {
return;
}
// Because the menu is shown at a location based on the initiating click, we need
// to fake up a mouse event to get the menu to show somewhere other than (0,0).
const { x, y, width, height } = button.getBoundingClientRect();
const mouseEvent = document.createEvent('MouseEvents');
// Types do not match signature
/* eslint-disable @typescript-eslint/no-explicit-any */
mouseEvent.initMouseEvent(
'click',
true, // bubbles
false, // cancelable
null as any, // view
null as any, // detail
0, // screenX,
0, // screenY,
x + width / 2,
y + height / 2,
false, // ctrlKey,
false, // altKey,
false, // shiftKey,
false, // metaKey,
false as any, // button,
document.body
);
/* eslint-enable @typescript-eslint/no-explicit-any */

button.dispatchEvent(mouseEvent);

event.preventDefault();
event.stopPropagation();
return;
}
const { x, y, width, height } = button.getBoundingClientRect();
const mouseEvent = new MouseEvent('pointerdown', {
bubbles: true,
cancelable: false,
composed: true,
view: window,
button: 0,
buttons: 1,
clientX: x + width / 2,
clientY: y + height / 2,
ctrlKey: false,
altKey: false,
shiftKey: false,
metaKey: false,
});

button.dispatchEvent(mouseEvent);

event.preventDefault();
event.stopPropagation();
return;
}

// Focus composer field
if (
Expand Down