fix: file preview closes on any click when opened from the Controls menu (#33831)

Opening a file from Controls → Files and clicking anything in its window, such as the Preview tab, closed the window together with the menu. Clicks inside a window opened from a menu no longer count as clicks outside it, so the preview stays open.

Fixes #33828
This commit is contained in:
Classic298 2026-11-06 16:50:09 +01:00 • committed by GitHub
parent d83e1caab4
commit d8dcb82cde
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -330,10 +330,10 @@
if (!(event.target instanceof Node)) return;
if (triggerEl?.contains(event.target)) return;
if (contentEl?.contains(event.target)) return;
// Submenus and listboxes can be portaled outside contentEl.
// Submenus, listboxes and modals can be portaled outside contentEl.
const portaled =
event.target instanceof Element
? event.target.closest('[role="menu"], [role="listbox"]')
? event.target.closest('[role="menu"], [role="listbox"], [aria-modal="true"]')
: null;
if (portaled && !portaled.contains(triggerEl)) return;
event.preventDefault();