Skip to content

Commit 70aee15

Browse files
committed
fix(scrollbar): fix scroll background opacity
1 parent 6d483fb commit 70aee15

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/textual/scrollbar.py

+2
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,8 @@ def render(self) -> RenderableType:
286286
else:
287287
background = styles.scrollbar_background
288288
color = styles.scrollbar_color
289+
base_background, _ = self.parent._opacity_background_colors
290+
background = base_background + background
289291
color = background + color
290292
scrollbar_style = Style.from_color(color.rich_color, background.rich_color)
291293
if self.screen.styles.scrollbar_color.a == 0:

tests/snapshot_tests/test_snapshots.py

+27
Original file line numberDiff line numberDiff line change
@@ -3251,3 +3251,30 @@ async def run_before(pilot: Pilot) -> None:
32513251
terminal_size=(175, 50),
32523252
run_before=run_before,
32533253
)
3254+
3255+
3256+
def test_scrollbar_background_with_opacity(snap_compare):
3257+
"""Regression test for https://github.com/Textualize/textual/issues/5458
3258+
The scrollbar background should match the background of the widget."""
3259+
3260+
class ScrollbarOpacityApp(App):
3261+
CSS = """
3262+
Screen {
3263+
align: center middle;
3264+
}
3265+
3266+
VerticalScroll {
3267+
width: 50%;
3268+
height: 50%;
3269+
background: blue 10%;
3270+
scrollbar-background: blue 10%;
3271+
scrollbar-color: cyan;
3272+
scrollbar-size-vertical: 10;
3273+
}
3274+
"""
3275+
3276+
def compose(self) -> ComposeResult:
3277+
with VerticalScroll():
3278+
yield Static("\n".join(f"This is some text {n}" for n in range(100)))
3279+
3280+
assert snap_compare(ScrollbarOpacityApp())

0 commit comments

Comments
 (0)