refactor(ui): fold the sidebar overlay exemption into the selector

Match the existing self-exclusion convention used by useWorkspaceBoardPanel
and AgentDashboardDrawer instead of a separate matches() guard, and drop the
non-null assertion from the test.

No behavior change.
This commit is contained in:
Neil
2026-09-06 14:12:24 -07:00
parent 66bb3ffd73
commit 04e727fa86
2 changed files with 4 additions and 6 deletions
+1 -1
View File
@@ -35,7 +35,7 @@ describe('hasVisibleOverlay', () => {
expect(hasVisibleOverlay()).toBe(false)
document.querySelector('[data-worktree-sidebar]')!.innerHTML = '<div role="menu"></div>'
mount('<div role="listbox" data-worktree-sidebar><div role="menu"></div></div>')
expect(hasVisibleOverlay()).toBe(true)
})
+3 -5
View File
@@ -1,4 +1,6 @@
const OVERLAY_SELECTOR = '[role="dialog"], [role="alertdialog"], [role="listbox"], [role="menu"]'
// The always-mounted worktree sidebar is page chrome, not an Escape-owning popup.
const OVERLAY_SELECTOR =
'[role="dialog"], [role="alertdialog"], [role="listbox"]:not([data-worktree-sidebar]), [role="menu"]'
type VisibleOverlayOptions = {
/** Overlays inside a match are treated as page content, not as a layer above it. */
@@ -15,10 +17,6 @@ export function hasVisibleOverlay(options?: VisibleOverlayOptions): boolean {
if (!(element instanceof HTMLElement)) {
return false
}
// The persistent workspace list is page chrome, not an Escape-owning popup.
if (element.matches('[role="listbox"][data-worktree-sidebar]')) {
return false
}
if (element.closest('[aria-hidden="true"]')) {
return false
}