fix(cloud): RR-b the sidebar's always-mounted listbox no longer swallows Escape (real-run find)

This commit is contained in:
Neil
2026-11-11 05:54:10 -08:00
parent ae48ab33ca
commit 99ffb4396b
2 changed files with 15 additions and 2 deletions
@@ -37,6 +37,16 @@ describe('Escape on the Orca Cloud setup page (RR-b)', () => {
expect(onExit).toHaveBeenCalledOnce()
})
it('an always-mounted list (the sidebar listbox) does not swallow Escape', () => {
const onExit = vi.fn()
const sidebar = document.createElement('div')
sidebar.setAttribute('role', 'listbox')
document.body.appendChild(sidebar)
renderHook(() => useEscapeExitsSetup(true, onExit))
pressEscape()
expect(onExit).toHaveBeenCalledOnce()
})
it('leaves Escape to a menu, popover or dialog on top, and does nothing while hidden', () => {
const onExit = vi.fn()
const { rerender } = renderHook(({ visible }) => useEscapeExitsSetup(visible, onExit), {
@@ -1,10 +1,13 @@
import { useEffect } from 'react'
/** Something on top of the page owns Escape (a menu, popover or dialog): leave it to that. */
/**
* Something open on top of the page owns Escape (a menu, a popover or popper list, a dialog): leave
* it to that. Always-mounted lists (the sidebar's worktree listbox) don't count.
*/
function escapeBelongsToOverlay(): boolean {
return (
document.querySelector(
'[role="dialog"], [role="menu"], [role="listbox"], [data-radix-popper-content-wrapper]'
'[role="dialog"][data-state="open"], [role="alertdialog"], [role="menu"], [data-radix-popper-content-wrapper]'
) !== null
)
}