Repository navigation
Roving arrow keys for groups on the page; radio_group on them (#346, PR 1) - #368
Merged
Merged
Conversation
A group on the page is declared with `NodeHandle::nav(Nav)`. The arrow keys move real focus through its items, which are the nodes under it that have an item role, now including `Tab` and `RadioButton`. The group is one Tab stop: the focused item, else the one marked `NodeHandle::selected`, else the first enabled one. The stop is settled before the widgets are drawn, so the item an arrow reaches can take the focus in the same frame. `Nav` gains `Row(Wrap)` (Left and Right, Home and End: a tab list) and `Radio(Wrap)` (all four arrows, no Home or End: a radio group). They run on one engine with the overlay's key tables. `selection_follows_focus()` makes an arrow activate the item it reaches, through the pending activation that Enter on a listbox uses. radio_group now uses the engine. Its private roving code is deleted (`navigate`, `take_focus_if_asked` and the FOCUS_REQUEST workaround). Behaviour-preserving: its tests pass unchanged, and no golden changed. Behaviour changes: - An overlay's items no longer include a nested group's items. - `Nav::Listbox` or `Nav::Submenu` on a page node is reported as `Problem::NavNeedsOverlay`, and the node is no group. Breaking: `Nav` has two new variants. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LesfK54UWq1haPSEr9X22o
# Conflicts: # tests/it/main.rs
This was referenced Nov 18, 2026
Owner
Author
|
Approved by the user (2026-11-18). Gate (my run with current main): |
samitbasu
added a commit
that referenced
this pull request
Nov 18, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
This was referenced Nov 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.
Part of #346: PR 1 of the design note, the core roving nav that the tabs widget will build on.
What changes
NodeHandle::nav(Nav)makes a node on the page a group whose items the arrow keys move the focus through, as overlays already do.selected, or else the first enabled item. The other items are left out of the Tab order.Navvariants on one engine. They share the item collection, the Tab-stop rule and the focus moves; only the key table differs.Nav::Row(Wrap): ←/→ move, and Home/End go to the ends. ↑/↓ are left alone. For a tab list.Nav::Radio(Wrap): all four arrows move, ↓/→ forward and ↑/← back, and Home/End are left alone. This is exactly the radio group's behaviour today.NodeHandle::selection_follows_focus()on a group: an arrow that moves the focus to an item also activates it, as a click would. It goes through the same pending activation that Enter on a listbox uses, soon_clickruns. Without it, the arrows only move the focus, and Enter or Space activates the item, as egui does for any focused clickable.NodeHandle::selected(Mark)marks the chosen item of its group, which makes that item the Tab stop while the focus is elsewhere. It is announced as its role says: a tab as selected, a radio button as checked.TabandRadioButtonare item roles (Nav's doc lists them).Problem::NavNeedsOverlay:nav(Nav::Listbox(..))ornav(Nav::Submenu(..))on a page node is reported, and the node is not a group.Nav::Nonemakes no group.radio_groupnow uses the engine.RadioButtonitems markedselected, and the column is aNav::Radio(Wrap::Around)group withselection_follows_focus().navigate,take_focus_if_askedand the egui-tempFOCUS_REQUESTworkaround. The workaround is no longer needed, because the item an arrow reaches is the Tab stop in that same frame.div_id_withon its slot, where before an anonymous div sat under a claimed key). The circles' paths and ids are unchanged.Breaking changes
NavgainedRowandRadio, so an exhaustivematchonNavoutside the crate needs two more arms.Problemis#[non_exhaustive], soNavNeedsOverlaybreaks nothing.Behaviour
Radio's behaviour is unchanged (it was declared behaviour-preserving): every existing test passes unmodified, and no golden changed.
Decisions
Picked by the user:
Nav::Row(Wrap)for tabs and toolbars, plusNav::Radio(Wrap)for radio, on one engine (option (a)). The note'sRowalone would have dropped radio's ↑/↓.Decided by default, for review:
selection_follows_focus()(the WAI-ARIA term), a group method. Radio uses it, and the tabs widget will use it for activation on focus and leave it off for.activate_on_enter()..activate_on_enter(), the tab an arrow reached would not be focusable and egui would drop the focus. Leaving the group and coming back with Shift+Tab lands on the selected item, as the APG tabs pattern says.selected(Mark)and notselected(bool), because of the no-naked-bool rule, andMarkis what the owned widgets already pass.selectedsets accesskit's checked state (toggled), notselected, which ARIA doesn't define for radios.Nav::MenuandNav::Gridare accepted on a page group too, with real focus and one Tab stop. OnlyListboxandSubmenu, which need an overlay, are refused.Tests
New in
tests/it/roving.rs, all built on the public API alone and driven by kittest key events through the real dispatch:the_list_is_one_tab_stop_on_the_selected_itemwith_nothing_selected_the_first_enabled_item_is_the_tab_stopleft_and_right_move_the_focus_and_wrap_and_home_and_end_go_to_the_ends(the selection does not move)up_and_down_do_nothing_in_a_rowa_row_that_stops_stays_on_its_endsthe_arrows_skip_a_disabled_itemtab_leaves_from_the_focused_item_and_comes_back_to_the_selected_oneenter_and_space_activate_the_focused_itemwhen_selection_follows_focus_an_arrow_activates_the_item_it_reaches(entering the group activates nothing; one activation per key)a_radio_nav_moves_on_all_four_arrows_and_leaves_home_and_end_alonethe_selected_tab_is_announced_as_selecteda_listbox_nav_on_a_page_node_is_reported_and_makes_no_groupin_a_menu::the_menus_arrows_pass_over_a_group_inside_itThe radio group's existing tests pass unchanged:
owned_choice(one Tab stop on the chosen option, all four arrows, Shift+Tab back), andchoices(disabled options skipped, wrapping).Reversion check: on main the new suite doesn't compile, because the API is new. Each mutation below fails tests, and the unmutated branch passes them all:
owned_choiceandchoicestoo);selection_follows_focusignored: 4 fail (radio's three, plus one roving);Radiotakes Home/End: 1 fails;selectednot announced: 1 fails;Wording for you to check: the existing
Navdoc now listsTabandRadioButtonamong the item roles, and says it also applies to a group on the page.TODO(prose)
NodeHandle::nav,NodeHandle::selection_follows_focus,NodeHandle::selected,Nav::Row,Nav::RadioandProblem::NavNeedsOverlayare one-liners or short drafts for you to rewrite.There's no UI change, so there is nothing to try by hand. The tabs widget (PR 3) and its gallery (PR 4) get the trial.
🤖 Generated with Claude Code
https://claude.ai/code/session_01LesfK54UWq1haPSEr9X22o