Skip to content

Commit 8002583

Browse files
authored
Stop command palette Input message leakage (#3322)
* Fix Input event leakage from Command Palette to app * Update the CHANGELOG
1 parent 427e45a commit 8002583

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1010
### Fixed
1111

1212
- Fixed the command palette crashing with a `TimeoutError` in any Python before 3.11 https://github.com/Textualize/textual/issues/3320
13+
- Fixed `Input` event leakage from `CommandPalette` to `App`.
1314

1415
## [0.37.0] - 2023-09-15
1516

src/textual/command.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,7 @@ def _input(self, event: Input.Changed) -> None:
876876
Args:
877877
event: The input event.
878878
"""
879+
event.stop()
879880
self.workers.cancel_all()
880881
search_value = event.value.strip()
881882
if search_value:
@@ -906,10 +907,14 @@ def _select_command(self, event: OptionList.OptionSelected) -> None:
906907

907908
@on(Input.Submitted)
908909
@on(Button.Pressed)
909-
def _select_or_command(self) -> None:
910+
def _select_or_command(
911+
self, event: Input.Submitted | Button.Pressed | None = None
912+
) -> None:
910913
"""Depending on context, select or execute a command."""
911914
# If the list is visible, that means we're in "pick a command"
912915
# mode...
916+
if event is not None:
917+
event.stop()
913918
if self._list_visible:
914919
# ...so if nothing in the list is highlighted yet...
915920
if self.query_one(CommandList).highlighted is None:

0 commit comments

Comments
 (0)