From 6e36aa7a8b2db666c500cf9741e4d2fc29a94428 Mon Sep 17 00:00:00 2001 From: trevor-signal <131492920+trevor-signal@users.noreply.github.com> Date: Tue, 22 Aug 2023 10:22:04 -0400 Subject: [PATCH] Improve reliability of click events for IncomingCallBar --- stylesheets/components/ConversationHeader.scss | 9 +++++++++ ts/background.ts | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/stylesheets/components/ConversationHeader.scss b/stylesheets/components/ConversationHeader.scss index 8ca264c89fe8..85f3f8ad9884 100644 --- a/stylesheets/components/ConversationHeader.scss +++ b/stylesheets/components/ConversationHeader.scss @@ -33,6 +33,15 @@ } -webkit-app-region: var(--draggable-app-region); + + // In Electron v23+, clicking on a `drag` region in an unfocused window may not + // propagate clicks to no-drag elements that have a higher CSS order; this avoids that + // scenario for interactive elements (e.g. IncomingCallBar) which overlap the + // conversation header. + @at-root body:not(.window-focused) & { + -webkit-app-region: no-drag; + } + padding-top: var(--title-bar-drag-area-height); display: flex; flex-direction: row; diff --git a/ts/background.ts b/ts/background.ts index 5c92a0b30c9a..f52e8b5eadf3 100644 --- a/ts/background.ts +++ b/ts/background.ts @@ -837,6 +837,14 @@ export async function startApp(): Promise { ); }); + window.document.body.classList.add('window-focused'); + window.addEventListener('focus', () => { + window.document.body.classList.add('window-focused'); + }); + window.addEventListener('blur', () => + window.document.body.classList.remove('window-focused') + ); + // How long since we were last running? const lastHeartbeat = toDayMillis(window.storage.get('lastHeartbeat', 0)); const previousLastStartup = window.storage.get('lastStartup');