-
Notifications
You must be signed in to change notification settings - Fork 815
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
It's possible to somehow break the working of TabbedContent
#2229
Comments
Hey @davep, can you be more specific about what I should see that is wrong, or how to trigger it exactly? I opened the app, I used the arrow keys and Enter to move around the directory trees, I can use the bindings to shift to different tabs, and everything seems to be working just fine. |
Try just holding the bound keys down and let it go full speed, letting it wrap around plenty of times. Hopefully the issue should appear. If not I'll retest here with main. |
I held down Shift + Right for a bit, then I let go. |
Yeah, that's it. |
I found a funnier way of triggering the issue: Add this handler to your app: class TabbedContentIssueApp(App[None]):
# ...
def key_p(self) -> None:
self.action_next()
self.action_next() If you press |
The actual issue can be more easily uncovered by pressing P on this app while connected to the devtools: Appfrom textual.app import App, ComposeResult
from textual.widgets import TabbedContent, TabPane, Tabs, Label
class MyApp(App[None]):
def compose(self) -> ComposeResult:
with TabbedContent():
with TabPane("one"):
yield Label("./")
with TabPane("two"):
yield Label("./")
with TabPane("three", id="three"):
yield Label("./")
def key_p(self) -> None:
self.query_one(Tabs).action_next_tab()
self.query_one(Tabs).action_next_tab()
app = MyApp()
if __name__ == "__main__":
app.run() What's happening? There is a potential loop between
This generally isn't an issue and |
* Add regression test for #2229. * Fix potential reactive-watch loop. * Simplify regression test. Labels are cheaper to use and the final visual result of the test won't depend on the directory it runs from. * Simplify solution. Turns out I didn't need a descriptor. :( * Fail on empty tab.
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
This one isn't exactly easy to explain, but hopefully easy to see and recreate with the following code (which is a distilled version of what I'm doing in a bigger application, where I found it).
Worth noting: the motivation here is that (in the application I'm working on) the
TabbedContent
is acting as a sidebar, where each pane has content that can be focused, and I want folk to be people to switch tabs without needing to navigate to the tab bar and back into the pane again. As such there's some bindings in place that call into theTabs
and uses their prev/next tab actions.In experimenting, it looks like the
SelfFocusPane.on_show
setting focus to the child of the pane is key here; remove that and I can't recreate the issue.The text was updated successfully, but these errors were encountered: