-
Notifications
You must be signed in to change notification settings - Fork 829
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
stopwatch key presses stop working after remove with focus #939
Comments
This also happens if the "Stop" button on the last stopwatch has focus when it is removed. |
Testing with 0.2.0b6 (I've not updated my beta sandbox locally yet), following the above, I get this crash instead:
On the surface it would appear it's a focus issue in Textual itself. |
And just to confirm: once updated to b7 I get the same as @aaronst. |
Also to add to the above, with b7: once the app is in the "won't respond to keyboard" state, none of the key bindings work either -- so no light/dark mode toggle, etc. As @aaronst says: once you've used the mouse to get some focus back everything works fine again. |
Could be related to #936? |
@davep That was fixed in this PR (and b7) - https://github.com/Textualize/textual/pull/936/files |
Aye, was just sort of suggesting that it might be something in Textual rather than in the stopwatch example. |
@davep Sorry, was referring to this crash:
|
This change ensures that, for example, the widget remains in the Screen.focus_chain so that it's easier to handle passing off focus on removal. To help address Textualize#939.
Rather than call on Screen._reset_focus, which seems to only really consider siblings, instead call on the being-removed widget's screen to find the previous widget that can receive focus. Addresses Textualize#939.
This change ensures that, for example, the widget remains in the Screen.focus_chain so that it's easier to handle passing off focus on removal. To help address Textualize#939.
Addresses the issue raised in Textualize#939. Here I rework Screen._reset_focus so that, rather than deal with siblings, it deals with the focus chain. It now also optionally takes a list of DOMNodes to avoid and will, as that suggests, avoid them when looking for somewhere to move focus to. As a preference the new version of this will seek to settle focus on the nearest (in the chain) *previous* non-excluded DOMNode. NOTE: Currently the return value of Widget.walk_children is cast to a list to ensure that it doesn't get consumed (as of the time of commit, it's still qan iterable). Once Textualize#952 has been accepted I'll change this (remove the cast).
Did we solve your problem? Consider buying the Textualize developers a coffee to say thanks. |
From the
css
branch on version0.2.0b7
, it looks like there is a bug in thedocs/example/tutorial/stopwatch.py
example or maybe something to do with focus.To reproduce, run
stopwatch.py
, usetab
to focus the "Reset" button on the last stopwatch, and then pressr
to remove it. After this, the app no longer responds to any key presses, includingctrl+c
. Using the mouse to click a button seems to get things working again.The text was updated successfully, but these errors were encountered: