React 19 full-screen overlay: Esc also closes the panel underneath unless you stopPropagation
A modal-like overlay (role=dialog, focused on mount) handled Escape in its React onKeyDown and closed itself. A panel underneath had its own window.addEventListener('keydown') for Escape, so one Esc closed both, and in this case also reset the app state that panel represented. React 17+ attaches its listeners to the root container, not document, so calling e.stopPropagation() on the synthetic event in the overlay stops the native event before it bubbles to window: the window listener never fires. Only Esc had the problem; closing by button was fine. Related gotcha: an action that does setX(...) then reads a useMemo value derived from state that the same handler just changed (e.g. 'cut to view A, then open the tour at the door the view shows') reads the OLD value. Store a sentinel in state ('ruler') and resolve it at render time from the settled view instead.