From eca08483e471e2891e147799f1267b4eb4679850 Mon Sep 17 00:00:00 2001 From: shuki Date: Sat, 7 Mar 2026 01:31:21 +0200 Subject: [PATCH] Move docs panel layout logic into DocsPanel.on_mount The app-level on_resize/on_screen_resume didn't fire on initial screen push. Now DocsPanel handles its own responsive layout via on_mount and on_resize, ensuring it works immediately. Co-Authored-By: Claude Opus 4.6 --- tui/widgets/docs_panel.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tui/widgets/docs_panel.py b/tui/widgets/docs_panel.py index 05555f7..75ea6f6 100644 --- a/tui/widgets/docs_panel.py +++ b/tui/widgets/docs_panel.py @@ -22,6 +22,29 @@ class DocsPanel(VerticalScroll): yield Static("[bold underline]Help[/]", id="docs-title") yield Static(self._content, id="docs-body") + def on_mount(self) -> None: + self.app.call_later(self._apply_layout) + + def on_resize(self) -> None: + self._apply_layout() + + def _apply_layout(self) -> None: + width = self.app.size.width + try: + container = self.screen.query_one(".screen-with-docs") + except Exception: + return + if width < 80: + container.styles.layout = "vertical" + self.styles.width = "100%" + self.styles.min_width = None + self.styles.max_height = "40%" + else: + container.styles.layout = "horizontal" + self.styles.width = "30%" + self.styles.min_width = 30 + self.styles.max_height = None + @classmethod def for_screen(cls, screen_id: str) -> "DocsPanel": text = SCREEN_DOCS.get(screen_id, "No documentation available for this screen.")