Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 12x 12x 10x 7x | /**
* Who a press of Escape belongs to, for a chat frame that leaves full
* screen (`ChatLayout`) or minimises (`ChatDock`) on it.
*
* One key should take one step back, so the frame gives way to anything
* open over the chat that closes on Escape itself: a modal dialog, a Radix
* dropdown or popover (the chat toolbar's model and tools menus, the dock's
* picker — Radix portals their content to <body> in that wrapper), or the
* composer's `/` command palette. The frames read the key in the capture
* phase, before any of those see it, so the check is of what is open now.
*/
/** Something open over the chat that takes Escape for itself. */
export const OVERLAY_OPEN =
'[aria-modal="true"], [data-radix-popper-content-wrapper]';
/** The composer while its command palette is open (`ChatPanel`). */
const PALETTE_OPEN = '[aria-autocomplete][aria-expanded="true"]';
/** True when this Escape is for something open over the chat, not for the
* frame around it. */
export function escapeTakenBelow(e: KeyboardEvent): boolean {
if (document.querySelector(OVERLAY_OPEN)) return true;
return e.target instanceof Element && !!e.target.closest(PALETTE_OPEN);
}
|