feat(ui): error & state UX (F4) #29
@@ -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