diff --git a/ui/frontend/src/lib/ui/sheet-dismiss.ts b/ui/frontend/src/lib/ui/sheet-dismiss.ts index f6c994a..5bcca66 100644 --- a/ui/frontend/src/lib/ui/sheet-dismiss.ts +++ b/ui/frontend/src/lib/ui/sheet-dismiss.ts @@ -25,7 +25,18 @@ export function sheetDismiss( let opts = options; const handle = node.querySelector("[data-sheet-handle]") ?? node; + // The sheet stays mounted on desktop but is hidden by a media query + // (`display: none`); the document-level tap-outside listener fires + // regardless of that, so it must no-op while the sheet is not shown, + // or any click would dismiss the current selection. `offsetParent` is + // unreliable here (it is null for `position: fixed`), so check the + // computed display directly. + function isHidden(): boolean { + return getComputedStyle(node).display === "none"; + } + function onDocumentPointerDown(event: PointerEvent): void { + if (isHidden()) return; const target = event.target; if (target instanceof Node && node.contains(target)) return; opts.onDismiss();