diff --git a/CHANGELOG.md b/CHANGELOG.md index a2d0758..63a4585 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Plain text files (`.txt`) are now saved with CRLF line endings on Windows. +- When closing dialogs, the character input no longer becomes focused. ### Fixed diff --git a/README.md b/README.md index 33a0353..f41a93e 100644 --- a/README.md +++ b/README.md @@ -216,7 +216,6 @@ To preview ANSI art files in file managers like Nautilus, Thunar, Nemo, or Caja, ### Misc - Extraneous undo states may be created in some cases. In particular, I noticed when undoing/redoing with free-typing mode, the last state had no cursor but was otherwise identical. - Document recovery dialog is shown unnecessarily if the backup file is identical. -- Closing dialogs focuses the character input which is undesirable as it prevents typing in the canvas or copying the selection with Ctrl+C etc. (You can use Esc to reset focus.) - Pressing a key to exit View Bitmap mode may cause unwanted side effects. - Pressing a key doesn't exit View Bitmap mode if the character input is focused. diff --git a/src/textual_paint/windows.py b/src/textual_paint/windows.py index 864d403..4fb8cbe 100644 --- a/src/textual_paint/windows.py +++ b/src/textual_paint/windows.py @@ -395,6 +395,8 @@ class Window(Container): def close(self) -> None: """Force close the window.""" + # Before removing from the DOM, unfocus, because otherwise Textual will try to focus a widget "nearby" in the focus order, in `_reset_focus`. + self.app.set_focus(None) self.remove() self.post_message(self.Closed())