Skip to content

[Bug] Dialog, Drawer, CommandPalette: a press that starts inside and ends on the backdrop closes the dialog #8964

Closed

Description

@duytbp

Description

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:

  1. 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.
  2. 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>
    </>
  );
}
  1. Open the dialog.
  2. Press inside the text of "Note", drag to select it, and release the mouse button outside the dialog, over the backdrop.
  3. The dialog closes.
  4. 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.

Astryx Version

@astryxdesign/[email protected], still present on main (14fc587)

Environment

Chrome on desktop with a mouse (the click goes to the common ancestor of the press and release targets). Not assistive-technology specific.

Activity

  1. added
    bug
    component
    on Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:corebugcomponent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions