-
Notifications
You must be signed in to change notification settings - Fork 788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Focussing a widget inside a tab should switch tabs #4593
Comments
I assume you mean when focusing a widget programmatically. Is my quick attempt at an example below a fair representation of this issue, where you would expect the tabs to switch automatically? from textual.app import App, ComposeResult
from textual.widgets import Button, Footer, TabbedContent, TabPane
class ExampleApp(App):
BINDINGS = [("space", "focus_button_2_2", "Focus button 2.2")]
def compose(self) -> ComposeResult:
with TabbedContent(id="tabbed-root"):
with TabPane("[red]Parent 1[/]"):
with TabbedContent():
with TabPane("[red]Child 1.1[/]"):
yield Button("Button 1.1", variant="error")
with TabPane("[red]Child 1.2[/]"):
yield Button("Button 1.2", variant="error")
with TabPane("[green]Parent 2[/]", id="parent-2"):
with TabbedContent(id="tabbed-parent-2"):
with TabPane("[green]Child 2.1[/]"):
yield Button("Button 2.1", variant="success")
with TabPane("[green]Child 2.2[/]", id="child-2-2"):
yield Button(
"Button 2.2",
variant="success",
id="button-2-2",
)
yield Footer()
def action_focus_button_2_2(self) -> None:
# self.query_one("#tabbed-root", TabbedContent).active = "parent-2"
# self.query_one("#tabbed-parent-2", TabbedContent).active = "child-2-2"
self.query_one("#button-2-2", Button).focus()
if __name__ == "__main__":
app = ExampleApp()
app.run() |
@TomJGooding Yes - I mean programmatically. Looks like your example captures it :) |
That's for the MRE Tom! |
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Right now the widget gets focused, but it's not visible.
Note that there can be many layers of tabs.
DescendantFocus
might come in handy.The text was updated successfully, but these errors were encountered: