From 2425ba260f9e53b20cc7c1b8a7c3273af48bef5e Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Tue, 10 May 2022 09:55:04 +0100 Subject: [PATCH] Ensure we dont overwrite style object injected into render --- sandbox/tabs.py | 3 ++- sandbox/uber.css | 5 +++++ src/textual/scrollbar.py | 14 +++++++------- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/sandbox/tabs.py b/sandbox/tabs.py index db12d8404..efcfcd7c8 100644 --- a/sandbox/tabs.py +++ b/sandbox/tabs.py @@ -145,4 +145,5 @@ class BasicApp(App): self.mount(example.widget) -BasicApp.run(css_path="tabs.scss", watch_css=True, log_path="textual.log") +app = BasicApp(css_path="tabs.scss", watch_css=True, log_path="textual.log") +app.run() diff --git a/sandbox/uber.css b/sandbox/uber.css index d392f2f65..e0ab19cc2 100644 --- a/sandbox/uber.css +++ b/sandbox/uber.css @@ -14,6 +14,11 @@ App.-show-focus *:focus { background: darkslateblue; } +#child2 { + text-style: underline; + background: red; +} + .list-item { height: 10; color: #12a0; diff --git a/src/textual/scrollbar.py b/src/textual/scrollbar.py index 2d8675da5..768720e06 100644 --- a/src/textual/scrollbar.py +++ b/src/textual/scrollbar.py @@ -206,17 +206,17 @@ class ScrollBar(Widget): yield "position", self.position def render(self, style: Style) -> RenderableType: - style = self.parent.styles - style = Style( + styles = self.parent.styles + scrollbar_style = Style( bgcolor=( - style.scrollbar_background_hover.rich_color + styles.scrollbar_background_hover.rich_color if self.mouse_over - else style.scrollbar_background.rich_color + else styles.scrollbar_background.rich_color ), color=( - style.scrollbar_color_active.rich_color + styles.scrollbar_color_active.rich_color if self.grabbed - else style.scrollbar_color.rich_color + else styles.scrollbar_color.rich_color ), ) return ScrollBarRender( @@ -224,7 +224,7 @@ class ScrollBar(Widget): window_size=self.window_size, position=self.position, vertical=self.vertical, - style=style, + style=scrollbar_style, ) async def on_event(self, event) -> None: