You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] Dialog, Drawer, CommandPalette: a press that starts inside and ends on the backdrop closes the dialog #8964
A light-dismissable Dialog (purpose="info"), a Drawer with scrim click, and CommandPalette (which renders Dialog with purpose="info", CommandPalette.tsx:662-675) close on any click whose target is the <dialog> itself (Dialog.tsx:661-665, Drawer.tsx:509-515). The comment above the handler assumes that "clicks on child content always target the child". They don't in two common cases:
A press that starts inside and ends on the backdrop. Selecting text in a field and releasing the button past the dialog's edge, or dragging a slider thumb out of it. The browser dispatches click to the nearest common ancestor of the pointerdown and pointerup targets, which is the <dialog>, so the dialog closes and the person's input is lost.
A backdrop press that only dismisses a popover inside the dialog. With a Selector list, a DropdownMenu or a Popover open inside the dialog, a press on the backdrop light-dismisses that popover and then also closes the dialog. One press dismisses two layers; for Escape, useLayerDismissal already makes one press close only the topmost layer.
Expected: the dialog closes only when the press both started and ended on the backdrop, with no other light-dismissable layer open above it. Tracking where pointerdown landed (as many dialog implementations do) covers case 1; asking the layer stack whether a layer above took the press covers case 2.
Reproduction
import {useState} from 'react';
import {Button, Dialog, DialogHeader, TextInput} from '@astryxdesign/core';
export function Repro() {
const [isOpen, setIsOpen] = useState(false);
const [note, setNote] = useState('A long note to select with the mouse');
return (
<>
<Button label="Open" onClick={() => setIsOpen(true)} />
<Dialog isOpen={isOpen} onOpenChange={setIsOpen} purpose="info">
<DialogHeader title="Note" />
<TextInput label="Note" value={note} onChange={setNote} />
</Dialog>
</>
);
}
Open the dialog.
Press inside the text of "Note", drag to select it, and release the mouse button outside the dialog, over the backdrop.
The dialog closes.
Reopen it, open any popover inside it (for example a Selector placed in the dialog), and press the backdrop once: the popover and the dialog both close.
Activity
fix(Dialog, Drawer): a backdrop press dismisses only when it starts a…