Skip to content

Children of Collapsible widget no longer focusable, when the container is expanded #6140

@laynal

Description

@laynal

As of Textual 6.0.0, widgets inside a collapsible container can no longer be tabbed through, when going from a state of collapsed to expanded.

Additional behaviours noticed:

  • Mounting an already expanded Collapsible widget, will show the original behaviour (i.e. children inside can be focused with tab);
  • Handling the Expanded event to give focus to a widget inside, will correctly pass focus to the widget, but tabbing again will give focus to the first widget in the compose method, instead of going to the next one;
  • Clicking a widget, inside the container, with the mouse and pressing tab will go through the same behaviour of the previous point.

MRE:

The MRE will show the button, inside the first expanded collapsible, as focusable while tabbing. Meanwhile, the input fields inside the second one will be skipped, when the container is opened.

Closing and reopening either Collapsible widget will leave the children inside unfocusable by tabbing.

from textual.app import App
from textual.widgets import Input, Collapsible, Button

class Collapsible_test(App):    
    def compose(self):
        yield Input()
        with Collapsible(collapsed=False):
            yield Button()
        with Collapsible():
            yield Input()
            yield Input()
        yield Input()

if __name__ == "__main__":
    app = Collapsible_test()
    app.run()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions