#7647·ariakit

Let Escape close popups that mark each other

Author: diegohazCreated Sep 25, 2026Updated Sep 26, 2026
Labelsbughas workarounda11yp2hard

Context

While fixing #7632 in #7644, a pre-commit review checked Escape with two open popups where neither is a React ancestor of the other. It found a state where Escape closes neither popup. #7644 doesn't change this.

Problem

An open non-modal Dialog and a ComboboxPopover that was already in the DOM before the dialog opened can both reject Escape:

typescript
<>
  <Ariakit.Dialog
    open={open}
    onClose={() => setOpen(false)}
    modal={false}
    hideOnInteractOutside={false}
    aria-label="Notice"
  />
  <Ariakit.ComboboxProvider>
    <Ariakit.Combobox />
    {/* Without unmountOnHide, the popover stays in the DOM while hidden. */}
    <Ariakit.ComboboxPopover>
      <Ariakit.ComboboxItem value="Apple" />
      <Ariakit.ComboboxItem value="Banana" />
    </Ariakit.ComboboxPopover>
  </Ariakit.ComboboxProvider>
</>

Open the dialog, focus the combobox, press ArrowDown twice so that Apple is active, and press Escape twice. The popover and the dialog both stay open. With the dialog closed, Escape closes the popover as usual.

A Combobox rendered as a TooltipAnchor gets stuck the same way, even without another dialog: focus it with the keyboard so that the Tooltip shows, press ArrowDown, and press Escape twice. The listbox and the tooltip stay open.

typescript
<Ariakit.TooltipProvider>
  <Ariakit.ComboboxProvider>
    <Ariakit.TooltipAnchor render={<Ariakit.Combobox />} />
    <Ariakit.Tooltip>Search fruits</Ariakit.Tooltip>
    <Ariakit.ComboboxPopover>{/* items */}</Ariakit.ComboboxPopover>
  </Ariakit.ComboboxProvider>
</Ariakit.TooltipProvider>

Keyboard users can't dismiss either popup with Escape until focus or the pointer moves elsewhere.

The likely mechanism, from reading dialog.tsx: an open dialog marks the elements outside it, including a popup that is rendered hidden in the DOM. When that popup opens later, it marks the earlier dialog. Both are then marked, so each one treats the other as the topmost popup and rejects Escape.

Pre-existing on main

Yes. A Playwright test in Chrome with trusted key presses, against main at 92dd555, kept both popups open after two Escape presses. This happened with React rendering into document and into an element, with and without portal on the popover. The tooltip case happened in all the same variants, and also inside a non-portaled Popover.

Why #7644 can finish without it

#7644 changes when a dialog decides on an Escape key press, not which dialogs mark each other. This case needs a change in how popups mark each other, which is separate from #7632.

Expected outcome

Escape closes the most recently opened popup, then the next one, and the popups never mark each other at the same time. Browser tests cover the dialog and tooltip cases.

Workaround

Add unmountOnHide to the ComboboxPopover (verified in Chrome)