From a83dc572dfe43af1ed734c7c0b3d61499ca5c7a7 Mon Sep 17 00:00:00 2001 From: Kislay Verma Date: Sun, 2 Jun 2024 02:10:03 +0530 Subject: [PATCH] overlay: Blur focused element while overlay is open. We blur the focused element when an overlay opens, and refocus it when the overlay is closed, to prevent side effects. What motivated this change was that opening a lightbox overlay from preview content while editing a message caused the escape key to close the message edit form instead of closing the overlay. --- web/src/overlays.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/web/src/overlays.ts b/web/src/overlays.ts index 4c50f7b8c3..6a3cc00622 100644 --- a/web/src/overlays.ts +++ b/web/src/overlays.ts @@ -111,7 +111,9 @@ export function open_overlay(opts: OverlayOptions): void { reset_state(); }, }; - + if (document.activeElement) { + $(document.activeElement).trigger("blur"); + } overlay_util.disable_scrolling(); opts.$overlay.addClass("show"); opts.$overlay.attr("aria-hidden", "false");