Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leave footer when pushing modal screen #2621

Merged
merged 2 commits into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Changed

- `Placeholder` now sets its color cycle per app https://github.com/Textualize/textual/issues/2590
- Footer now clears key highlight regardless of whether it's in the active screen or not https://github.com/Textualize/textual/issues/2606

### Removed

Expand Down
3 changes: 1 addition & 2 deletions src/textual/widgets/_footer.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ def _on_mouse_move(self, event: events.MouseMove) -> None:

def _on_leave(self, _: events.Leave) -> None:
"""Clear any highlight when the mouse leaves the widget"""
if self.screen.is_current:
self.highlight_key = None
self.highlight_key = None

def __rich_repr__(self) -> rich.repr.Result:
yield from super().__rich_repr__()
Expand Down
28 changes: 28 additions & 0 deletions tests/test_footer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from textual.app import App, ComposeResult
from textual.geometry import Offset
from textual.screen import ModalScreen
from textual.widgets import Footer, Label


async def test_footer_highlight_when_pushing_modal():
"""Regression test for https://github.com/Textualize/textual/issues/2606"""

class MyModalScreen(ModalScreen):
def compose(self) -> ComposeResult:
yield Label("apple")

class MyApp(App[None]):
BINDINGS = [("a", "p", "push")]

def compose(self) -> ComposeResult:
yield Footer()

def action_p(self):
self.push_screen(MyModalScreen())

app = MyApp()
async with app.run_test(size=(80, 2)) as pilot:
await pilot.hover(None, Offset(0, 1))
await pilot.click(None, Offset(0, 1))
assert isinstance(app.screen, MyModalScreen)
assert app.screen_stack[0].query_one(Footer).highlight_key is None