Skip to content

Commit

Permalink
Stop command palette Input message leakage (#3322)
Browse files Browse the repository at this point in the history
* Fix Input event leakage from Command Palette to app

* Update the CHANGELOG
  • Loading branch information
davep authored Sep 16, 2023
1 parent 427e45a commit 8002583
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 6 additions & 1 deletion src/textual/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 8002583

Please sign in to comment.