Skip to content
Discussion options

You must be logged in to vote

The automatic focus move in the first example comes from hiding the focused
Input, rather than ContentSwitcher selecting the next form field.

ContentSwitcher.current changes which immediate child is displayed. When the
old input becomes hidden, Textual resets its focus. In the reset path for a
widget that's no longer in the focus chain, it looks for a visible, focusable
sibling. In your first example, input-1 is a sibling of input-0. In the
second, the focused input is inside the container, so input-1 is not its
sibling. That path leaves the app with no focused widget.

For a form with a known next step, explicitly focus the next input after
switching:

def on_input_submitted(self):
    cs = …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@robvanderleek
Comment options

Answer selected by robvanderleek
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants