mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Additional sleep after tabbing to guard vs races
This commit is contained in:
@@ -632,6 +632,12 @@ class App(Generic[ReturnType], DOMNode):
|
||||
print(f"press {key!r} (char={char!r})")
|
||||
key_event = events.Key(self, key, char)
|
||||
driver.send_event(key_event)
|
||||
# TODO: A bit of a fudge - extra sleep after tabbing to help guard against race
|
||||
# condition between widget-level key handling and app/screen level handling.
|
||||
# More information here: https://github.com/Textualize/textual/issues/1009
|
||||
# This conditional sleep can be removed after that issue is closed.
|
||||
if key == "tab":
|
||||
await asyncio.sleep(0.05)
|
||||
await asyncio.sleep(0.02)
|
||||
|
||||
await app._animator.wait_for_idle()
|
||||
|
||||
@@ -58,9 +58,9 @@ def test_checkboxes(snap_compare):
|
||||
def test_input_and_focus(snap_compare):
|
||||
press = [
|
||||
"tab",
|
||||
*list("Darren"), # Focus first input, write "Darren"
|
||||
*"Darren", # Focus first input, write "Darren"
|
||||
"tab",
|
||||
*list("Burns"), # Tab focus to second input, write "Burns"
|
||||
*"Burns", # Tab focus to second input, write "Burns"
|
||||
]
|
||||
assert snap_compare("docs/examples/widgets/input.py", press=press)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user