Skip to content

Run Input and TextArea key bindings inline to keep ordering with type…#6631

Open
dobbydobap wants to merge 1 commit into
Textualize:mainfrom
dobbydobap:fix-6605-input-key-order
Open

Run Input and TextArea key bindings inline to keep ordering with type…#6631
dobbydobap wants to merge 1 commit into
Textualize:mainfrom
dobbydobap:fix-6605-input-key-order

Conversation

@dobbydobap

Copy link
Copy Markdown

What this does: Printable characters are handled directly in Input._on_key / TextArea._on_key, but bound keys (backspace, arrows, ctrl+k, …) bubbled up to the app before their action ran. Under fast input the next character could be inserted while a bound key was still in transit, so operations applied out of order. This adds a small Widget._run_key_bindings helper that runs the widget's own non-priority bindings inline in _on_key, using the same run_action resolution the app would use. Since the focused widget is the first namespace in the binding chain anyway, and priority bindings are checked before the event reaches the widget, what runs is unchanged only when.

Why: Fixes #6605.

How I tested it: New regression tests post b, a, backspace, c without waiting between keys; on main they produce ba, with the fix bc. Full suite passes locally on Windows (3460 passed; one unrelated pre-existing failure in test_suspend that also fails on a clean checkout on my machine).

Notes: MaskedInput inherits Input's handler, so it's covered. Keys bound on ancestor widgets can in principle still reorder relative to typing, but the widget's own editing keys the case in the issue can't anymore. Happy to adjust the approach if you'd rather fix this at a different level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Input/Textarea action synchronization bug

1 participant