fix(ui): bottom-sheet tap-outside only fires while the sheet is shown
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) <noreply@anthropic.com>
This commit is contained in:
@@ -25,7 +25,18 @@ export function sheetDismiss(
|
|||||||
let opts = options;
|
let opts = options;
|
||||||
const handle = node.querySelector<HTMLElement>("[data-sheet-handle]") ?? node;
|
const handle = node.querySelector<HTMLElement>("[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 {
|
function onDocumentPointerDown(event: PointerEvent): void {
|
||||||
|
if (isHidden()) return;
|
||||||
const target = event.target;
|
const target = event.target;
|
||||||
if (target instanceof Node && node.contains(target)) return;
|
if (target instanceof Node && node.contains(target)) return;
|
||||||
opts.onDismiss();
|
opts.onDismiss();
|
||||||
|
|||||||
Reference in New Issue
Block a user