diff --git a/CHANGELOG.md b/CHANGELOG.md index 73f39b3773..51e2338d84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed - Fixed the command palette crashing with a `TimeoutError` in any Python before 3.11 https://github.com/Textualize/textual/issues/3320 +- Fixed `Input` event leakage from `CommandPalette` to `App`. ## [0.37.0] - 2023-09-15 diff --git a/src/textual/command.py b/src/textual/command.py index 0a11cba78f..2aafa10abe 100644 --- a/src/textual/command.py +++ b/src/textual/command.py @@ -876,6 +876,7 @@ def _input(self, event: Input.Changed) -> None: Args: event: The input event. """ + event.stop() self.workers.cancel_all() search_value = event.value.strip() if search_value: @@ -906,10 +907,14 @@ def _select_command(self, event: OptionList.OptionSelected) -> None: @on(Input.Submitted) @on(Button.Pressed) - def _select_or_command(self) -> None: + def _select_or_command( + self, event: Input.Submitted | Button.Pressed | None = None + ) -> None: """Depending on context, select or execute a command.""" # If the list is visible, that means we're in "pick a command" # mode... + if event is not None: + event.stop() if self._list_visible: # ...so if nothing in the list is highlighted yet... if self.query_one(CommandList).highlighted is None: