Prevent reactive-watcher loop in Tabs / TabbedContent. (#2305)

* 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.
This commit is contained in:
Rodrigo Girão Serrão
2023-04-18 11:48:33 +01:00
committed by GitHub
parent 3a7cf08ef2
commit 66a644845b
5 changed files with 196 additions and 20 deletions

View File

@@ -0,0 +1,24 @@
"""Regression test for https://github.com/Textualize/textual/issues/2229."""
from textual.app import App, ComposeResult
from textual.widgets import TabbedContent, TabPane, Tabs, Label
class QuicklyChangeTabsApp(App[None]):
def compose(self) -> ComposeResult:
with TabbedContent():
with TabPane("one"):
yield Label("one")
with TabPane("two"):
yield Label("two")
with TabPane("three", id="three"):
yield Label("three")
def key_p(self) -> None:
self.query_one(Tabs).action_next_tab()
self.query_one(Tabs).action_next_tab()
app = QuicklyChangeTabsApp()
if __name__ == "__main__":
app.run()