mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
This fixes #3633 by ensuring that if a query is made against the app while the command palette is active, the query trickles down to the previously-active screen rather than into the command palette modal screen. This also updates the command palette unit tests to take this change into account.
26 lines
792 B
Python
26 lines
792 B
Python
from textual.app import App
|
|
from textual.command import CommandPalette, Hit, Hits, Provider
|
|
|
|
|
|
class SimpleSource(Provider):
|
|
async def search(self, query: str) -> Hits:
|
|
def goes_nowhere_does_nothing() -> None:
|
|
pass
|
|
|
|
yield Hit(1, query, goes_nowhere_does_nothing, query)
|
|
|
|
|
|
class CommandPaletteApp(App[None]):
|
|
COMMANDS = {SimpleSource}
|
|
|
|
def on_mount(self) -> None:
|
|
self.action_command_palette()
|
|
|
|
|
|
async def test_clicking_outside_command_palette_closes_it() -> None:
|
|
"""Clicking 'outside' the command palette should make it go away."""
|
|
async with CommandPaletteApp().run_test() as pilot:
|
|
assert isinstance(pilot.app.screen, CommandPalette)
|
|
await pilot.click()
|
|
assert not isinstance(pilot.app.screen, CommandPalette)
|