Repository navigation
Give the keyboard an explicit layer stack - #780
Merged
Merged
Conversation
`keyboard/layer-stack.js` replaces `keyboard/return-stack.js` and `runtime/native-layers.js` with one ordered list of what stands over the page. A popover or modal dialog pushes an entry as it opens, and a command that enters a temporary surface pushes a return frame or adopts the layer its own run opened, so one gesture leaves one entry. Every read prunes the stack, keeping an entry under an active modal suspended with the frame it carries, and `current()` is the top entry when that entry carries a live frame. The monotonic order counter and the ancestor walks it was compared against are gone with it. `stack()` in the dispatcher drops the popover, modal and covering branches that inferred the layer situation from focus ancestry on every press. It tiers the scopes over the stack instead: each layer takes the scopes rooted inside it, the topmost layer also takes the focused control, explicitly inner modes and the return frame, and a boundary follows each layer. The newest modal, or a covering auxiliary surface, is the floor, and what that floor makes inert stays out of reach however near the reader it stands. The covering auxiliary surface stays off the stack on purpose, so a frame entered while its panel stood beside the page survives a resize into the covering posture and back. `openAuxiliarySurfaceFor` and the modality's `openSurfaceFor` go with the order comparison that was their only reader. Co-Authored-By: Claude Fable 5.1 <[email protected]>
A reopened popover took back its old entry, frame and origin included, whenever the stack had not been read since the surface closed. That let a pointer-reopened popover restore an origin the reader never asked to return to. Now a modal marks the entries beneath it as suspended when it is pushed, before the native call hides the popovers under it, and an opening lifts an existing entry only when it is standing or carries that mark. A closed entry is pruned and its reopening starts fresh; the command reference's re-show still finds its suspended entry. The header names the one layer this module cannot hear: a popover opened declaratively inside an undeclared shadow root. The keyboard guidance calls the entries return frames in every file, the `closedby` rule lives only in the module that owns it, and the glossary names the layer stack. TODO #24 leaves, since the stack landed; the invoker-commands row now states what a pointer-opened surface still lacks. Co-Authored-By: Claude Fable 5.1 <[email protected]>
# Conflicts: # TODO.md
The showPopover patch declared the layer after the native call, when the surface was already standing, so a popover a light dismissal had closed and a script then reopened lifted its old entry, frame and origin included, and Escape would have restored a place the reader never asked to return to. It now declares before the call, as the showModal patch does, so the stack sees the surface closed and starts a fresh entry. One opening is then declared twice, by the patch and by beforetoggle, and the second finds the lifted entry not yet open, so the suspension mark now lasts until the entry is next seen standing rather than clearing on the lift. The layer test pins the reopening with a popover in an undeclared shadow root, where only the patched method can declare it. Co-Authored-By: Claude Fable 5.1 <[email protected]>
leaf-agent
approved these changes
Sep 18, 2026
This was referenced Sep 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
keyboard/layer-stack.jsreplaceskeyboard/return-stack.jsandruntime/native-layers.jswith one ordered stack of what stands over the page: auto popovers, modal dialogs, and the return frames commands push when they enter a temporary surface. An opener pushes its entry as the surface opens, and a command whose own run opened a native layer adopts that entry, so one gesture leaves one entry. This isTODO.md's architecture item 24, which the branch removes from the list.stack()inkeyboard/dispatch.jsnow reads that stack rather than inferring the layer situation from:popover-openanddialog:modalancestry on every press. It tiers the scopes over the stack in one loop from the top down: each layer takes the scopes rooted inside it, the topmost layer also takes the focused control, explicitly inner modes and the return frame, and a boundary follows each layer. The newest modal is the floor. A covering auxiliary surface stays out of the stack and becomes the floor when no modal stands, so a frame entered while its panel stood beside the page survives a resize into the covering posture and back.Two tiering changes are observable, and both close holes. A popover standing above a modal but not nested inside it keeps its own scopes. Widget scopes in a shadow root under the covering panel are reachable.
A review of the first commit found that a popover closed by light dismissal and reopened by script could take back its old entry, frame and origin included, so Escape would have restored a place the reader never asked to return to. A modal now marks the entries beneath it as suspended when it is pushed, and the popover patch declares the layer before the native call rather than after, so the stack sees the surface closed and starts a fresh entry. A new case in
test_native_top_layers_bound_the_keyboard_stackpins that, using a popover in an undeclared shadow root where only the patched method can declare the opening.Run green on the branch locally: the four keyboard-facing nightly files (
test_render_navigation,test_render_controls,test_render_startup,test_render_widgets), pre-commit, and the everyday gate.🤖 Generated with Claude Code