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.
This commit is contained in:
Kislay Verma 2024-06-02 02:10:03 +05:30 committed by Tim Abbott
parent 1d7e0367b8
commit a83dc572df
1 changed files with 3 additions and 1 deletions

View File

@ -111,7 +111,9 @@ export function open_overlay(opts: OverlayOptions): void {
reset_state(); reset_state();
}, },
}; };
if (document.activeElement) {
$(document.activeElement).trigger("blur");
}
overlay_util.disable_scrolling(); overlay_util.disable_scrolling();
opts.$overlay.addClass("show"); opts.$overlay.addClass("show");
opts.$overlay.attr("aria-hidden", "false"); opts.$overlay.attr("aria-hidden", "false");