Skip to content

[Bug] Dialog, Drawer, CommandPalette: a backdrop press that closes a popover inside also closes the dialog #9920

Closed

Description

@duytbp

Description

With a menu or popover open inside a light-dismissable Dialog (purpose="info"), a Drawer with its scrim, or CommandPalette, one press on the backdrop closes both layers. The browser light-dismisses the popover="auto" layer on that press, and the click that follows on the <dialog> closes the dialog as well.

This is case 2 of #8964. #9613 fixed case 1 (a press that crosses the dialog's edge) and left this case out: "Case 2 in the issue (a backdrop press that also closes a popover inside) isn't part of this ruling and isn't changed." Nothing tracks it since #8964 closed.

useBackdropPress (useBackdropPress.ts:33-80), which Dialog and Drawer share, checks only that the press went down and came up on the <dialog> itself. A press on the backdrop while a popover shows does both, so it dismisses. family:overlay-dismissal states the intent as "A person dismissing layered UI should affect only the topmost relevant surface", and Escape already works that way: the first Escape closes the popover and the second closes the dialog.

Expected: a backdrop press that light-dismisses a layer open above the dialog closes only that layer. The next backdrop press closes the dialog. One way is to note at pointerdown whether a layer opened from the dialog's content is showing (for example, an element inside the dialog that matches :popover-open), and not count that press as a backdrop press. A design-system layer we maintain on Astryx does this in a capture-phase pointerdown listener on the <dialog>.

Reproduction

import {useState} from 'react';
import {Dialog, DropdownMenu} from '@astryxdesign/core';

export function Repro() {
  const [isOpen, setIsOpen] = useState(true);
  return (
    <Dialog isOpen={isOpen} onOpenChange={setIsOpen} purpose="info" aria-label="Note">
      <DropdownMenu
        button={{label: 'Actions'}}
        items={[
          {label: 'Rename', onClick: () => {}},
          {label: 'Archive', onClick: () => {}},
        ]}
      />
    </Dialog>
  );
}
  1. Click "Actions". The menu opens inside the dialog.
  2. Click once on the backdrop, away from the dialog.
  3. The menu closes, and the dialog closes with it (onOpenChange(false)).
  4. Expected: only the menu closes, as the first Escape would.

The same happens with a Drawer (scrim on, default purpose) that holds the same menu. CommandPalette renders Dialog with purpose="info", so it shares the path. Measured in Chromium with real mouse clicks (Playwright): the dialog had one :popover-open element before the backdrop click, then none, and the <dialog> was closed.

Astryx Version

@astryxdesign/[email protected]; useBackdropPress.ts is unchanged on main (75cc951)

Environment

Chromium 156 (Playwright 1.64), Linux, mouse. Not tied to one browser: a browser that supports the Popover API light-dismisses the popover on the press and then sends click to the <dialog>.

Activity

  1. added a commit that references this issue on Nov 5, 2026
    a866c2a
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions