From b38d170768cc09d59e4c22d525ff70b34b97783e Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Mon, 17 Feb 2025 13:41:08 +0000 Subject: [PATCH 1/2] :lipstick: Ensure the header stays visible for command line on top --- src/hike/screens/main.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/hike/screens/main.py b/src/hike/screens/main.py index 5233f01..9a46797 100644 --- a/src/hike/screens/main.py +++ b/src/hike/screens/main.py @@ -13,7 +13,7 @@ # Textual imports. from textual import on, work from textual.app import ComposeResult -from textual.containers import Horizontal +from textual.containers import Horizontal, VerticalGroup from textual.reactive import var from textual.widgets import Footer, Header, Markdown @@ -172,10 +172,11 @@ def __init__(self, arguments: Namespace) -> None: def compose(self) -> ComposeResult: """Compose the content of the screen.""" yield Header() - with Horizontal(id="workspace"): - yield Navigation(classes="panel") - yield Viewer(classes="panel") - yield CommandLine(classes="panel") + with VerticalGroup(): + with Horizontal(id="workspace"): + yield Navigation(classes="panel") + yield Viewer(classes="panel") + yield CommandLine(classes="panel") yield Footer() def on_mount(self) -> None: @@ -334,6 +335,8 @@ def check_action(self, action: str, parameters: tuple[object, ...]) -> bool | No Returns: `True` if it can perform, `False` or `None` if not. """ + if not self.is_mounted: + return True if action == Forward.action_name(): return self.query_one(Viewer).history.can_go_forward or None if action == Backward.action_name(): From 03ca9aa4aee42ff502d79d6047c1046370fc3807 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Mon, 17 Feb 2025 13:53:37 +0000 Subject: [PATCH 2/2] :bulb: Leave a note for myself about defensive check_action --- src/hike/screens/main.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/hike/screens/main.py b/src/hike/screens/main.py index 9a46797..3d428a1 100644 --- a/src/hike/screens/main.py +++ b/src/hike/screens/main.py @@ -336,6 +336,11 @@ def check_action(self, action: str, parameters: tuple[object, ...]) -> bool | No `True` if it can perform, `False` or `None` if not. """ if not self.is_mounted: + # Surprisingly it seems that Textual's "dynamic bindings" can + # cause this method to be called before the DOM is up and + # running. This breaks the rule of least astonishment, I'd say, + # but okay let's be defensive... (when I can come up with a nice + # little MRE I'll report it). return True if action == Forward.action_name(): return self.query_one(Viewer).history.can_go_forward or None