Repository navigation
Conversation
An owned control couldn't be the one an overlay opens on, and an app couldn't focus a field once at a moment of its choosing whether the field was new that frame or already built. The crate-internal Autofocus gains OnOverlayOpen and Now(Select), so the modes stay one value and can't be combined. Each focusable chain holds one autofocus field: it marks its focus node at build (Autofocus::open_focus) and applies it to that widget's response at draw. The public methods are one line each: focus_on_open(), and focus_now(), which is focus_now(Select) on the text field and the stepper. The radio group and the segmented control target their chosen item, else the first enabled one. Behaviour change: a node marked focus_on_open now gives the overlay's focus to the first focusable widget registered inside it, the node itself or one within. Before, a marked node that wasn't itself the widget was passed over. The stepper's and an icon text field's edit sits inside their marked leaf under its own id. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LesfK54UWq1haPSEr9X22o
# Conflicts: # src/owned/button.rs
Owner
Author
|
Approved by the user on its tests (2026-11-19). GitHub's required checks pass on the branch merged with current main. Merging. |
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 #326 (its item 2,
focus_on_openon the owned chains). Closes #395.What changes
.focus_on_open()and.focus_now(..):.focus_on_open()marks the node holding the chain's focusable widget, asNodeHandle::focus_on_opendoes. The overlay the control is in opens with focus on it, instead of on the overlay's first focusable..focus_now(..)(Focus: a one-shot app focus request for a field, new or existing #395) focuses the control on every frame it's set, whether the control is new that frame or already built. The app sets it on the frame it wants and drops it after, e.g..when(open_now, |c| c.focus_now(Select::All))..focus_now(Select), and it selects asSelectsays: withSelect::All, typing replaces the text..focus_now(), with no argument (the user's pick).Autofocusholds both:OnOverlayOpenandNow(Select), besideNever,OnAppearandOnChange.autofocusfield. At build it marks its focus node withautofocus.open_focus(), and at draw it runsautofocus.apply(..)on that widget's response. Each public method is one line that sets the field.Focustrait lands, those methods move into the trait.NodeHandle::focus_on_open(behaviour change): a marked node now gives the overlay's focus to the first focusable widget registered inside it: the node itself, or a widget within it.Decided by default, for review
The user picked
focus_now(Select)for the text chains,focus_now()elsewhere, and nofocus_nowon menu items. These were left to my defaults:ButtonChain. The dropdown menu passes its setting to its trigger button.custom, whose focusable is the caller's own content, soNodeHandle::focus_on_openalready serves it;table, whose rows aren't Tab stops;focus_on_open.focus_nowinside an overlay that is opening: on the frame the overlay opens, its opening focus is requested after the draw, so it wins, as withfocus_on_appeartoday.focus_on_openis the way to choose that focus.Wording for you to check:
NodeHandle::focus_on_open's doc now says "the node, or a widget inside it, must take focus", andopening_focus's doc follows it.Tests
New in
tests/it/focus_options.rs. Each test runs every chain through the real build, layout and draw, using kittest's focus and key events:without_the_option_a_popover_opens_on_its_first_focusable, a precondition: the button placed before the control would take focus by default.a_popover_opens_on_the_control_marked_focus_on_open: for each of the 13 chains, focus lands on its focus node (the chosen circle, the pressed cell, the thumb, the stepper's field, and so on), with no reports.of_two_controls_marked_focus_on_open_the_first_takes_focus_and_it_is_reportedfocus_on_open_on_the_page_takes_no_focusfocus_now_focuses_a_control_already_builtfocus_now_focuses_a_control_built_that_frameonce_the_app_drops_focus_now_focus_is_left_where_the_user_puts_itfocus_now_selecting_all_lets_typing_replace_a_field_s_text,focus_now_selecting_nothing_types_beside_the_textandfocus_now_selecting_all_lets_typing_replace_a_stepper_s_numberEvery existing test passes unchanged, and no golden changed.
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 all 159
focustests:focus_on_openmarks no node: 2 fail;focus_nowrequests no focus: 6 fail;focus_nowignores itsSelect: 2 fail (field and stepper);Checks
cargo test -p eggshell-uipasses: lib 316,it1631, doctests 92 and 15.TODO(prose)
Every new public method (
focus_on_openandfocus_nowon each chain) has a one-line draft for you to rewrite.🤖 Generated with Claude Code
https://claude.ai/code/session_01LesfK54UWq1haPSEr9X22o