mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 02:47:34 +00:00
fix(cloud): RR-b the sidebar's always-mounted listbox no longer swallows Escape (real-run find)
This commit is contained in:
@@ -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
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user