From 35e27c5aecdb687737dad64bdbcace7e1d4267cc Mon Sep 17 00:00:00 2001 From: Ilia Denisov Date: Fri, 22 May 2026 13:45:41 +0200 Subject: [PATCH] fix(ui): bottom-sheet tap-outside only fires while the sheet is shown MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The planet/ship-group sheets stay mounted on desktop but are hidden by a media query (`display: none`); the document-level tap-outside listener fired regardless, so the first click after selecting a planet cleared the selection — breaking every desktop inspector/select flow in CI. Guard the handler on the sheet's computed display (`offsetParent` is unreliable for `position: fixed`). The swipe handle is naturally inert when hidden. Co-Authored-By: Claude Opus 4.7 (1M context) --- ui/frontend/src/lib/ui/sheet-dismiss.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) 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();