Conversation
`SidebarMenuItem` rendered a plain `div` with `on_click`, so nothing in the sidebar subtree tracked focus: Tab could not reach a single item, and a keyboard user had no way to open a page. A downstream app had to rebuild the item on `base::Button` for that one reason. The row now owns a keyed focus handle the way `Button` does. It is a tab stop by default, draws the framework focus ring while focused, and activates on Enter or Space through GPUI's keyboard click. A pointer press does not move focus, so the ring only shows during keyboard navigation. Disabled items stay out of the traversal. `tab_stop`, `tab_index` and `FocusableExt::focus_ring` are exposed for the cases that need to opt out. The row's `overflow_x_hidden` goes away because it would clip the ring; the label containers already clip. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Problem
SidebarMenuItemwas a plaindiv+on_click; nothing incrates/component/src/sidebar/calledtrack_focus. GPUI's tab-stop table only lists nodes that painted with a tracked focus handle, so no sidebar item could be reached with Tab, and a keyboard user had no way to open a page.Reported from a downstream application (ai-desktop/pilot, issue #230 there): the settings dialog's nine pages were unreachable, and the app rebuilt the item on
gpui_kit::base::Buttonfor that one reason.Change
(id, "focus")), the same pattern asButton. It is a tab stop by default and activates on Enter / Space through GPUI's keyboard click, soon_clickreceivesClickEvent::Keyboard.focus_ring_stylewhile focused. A left mouse press callsprevent_default, asButtondoes, so the ring shows only during keyboard navigation.tab_stop(bool),tab_index(isize), andimpl FocusableExt(focus_ring(false)) for containers that clip the ring and draw their own.Role::Buttonand anaria_labelfrom the item label.overflow_x_hidden: it would clip the outward ring, and the label containers inside already clip.Tests
crates/component/src/sidebar/menu.rs:tab_reaches_each_enabled_item_and_enter_activates_it— Tab walksInbox→Sent→ wraps, skipping the disabled item and thetab_stop(false)item; Enter fires eachon_click.space_activates_the_focused_item.Both fail on
main(no item is ever focused) and pass here.Docs
website/component/sidebar.mdandwebsite/zh-CN/component/sidebar.mdgain a "Keyboard Access / 键盘可达" section.🤖 Generated with Claude Code