mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
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:
committed by
GitHub
parent
3a7cf08ef2
commit
66a644845b
24
tests/snapshot_tests/snapshot_apps/quickly_change_tabs.py
Normal file
24
tests/snapshot_tests/snapshot_apps/quickly_change_tabs.py
Normal 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()
|
||||
Reference in New Issue
Block a user