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

fix(scrollbar): fix scrollbar background opacity #5462

Merged
Show file tree
Hide file tree
Changes from 5 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 @@ -44,6 +44,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Fixed select refocusing itself too late https://github.com/Textualize/textual/pull/5420
- Fixed Log widget not refreshing on resize https://github.com/Textualize/textual/pull/5460
- Fixed special case with calculating the height of a container where all children have dynamic heights https://github.com/Textualize/textual/pull/5463
- Fixed scrollbars ignoring background opacity https://github.com/Textualize/textual/issues/5458


## [1.0.0] - 2024-12-12
Expand Down
3 changes: 3 additions & 0 deletions src/textual/scrollbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,9 @@ def render(self) -> RenderableType:
else:
background = styles.scrollbar_background
color = styles.scrollbar_color
if background.a > 0:
willmcgugan marked this conversation as resolved.
Show resolved Hide resolved
base_background, _ = self.parent._opacity_background_colors
background = base_background + background
color = background + color
scrollbar_style = Style.from_color(color.rich_color, background.rich_color)
if self.screen.styles.scrollbar_color.a == 0:
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions tests/snapshot_tests/test_snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -3284,3 +3284,30 @@ def on_mount(self) -> None:
t1.add_row(str(number) + " " * 200)

snap_compare(MyApp())


def test_scrollbar_background_with_opacity(snap_compare):
"""Regression test for https://github.com/Textualize/textual/issues/5458
The scrollbar background should match the background of the widget."""

class ScrollbarOpacityApp(App):
CSS = """
Screen {
align: center middle;
}

VerticalScroll {
width: 50%;
height: 50%;
background: blue 10%;
scrollbar-background: blue 10%;
scrollbar-color: cyan;
scrollbar-size-vertical: 10;
}
"""

def compose(self) -> ComposeResult:
with VerticalScroll():
yield Static("\n".join(f"This is some text {n}" for n in range(100)))

assert snap_compare(ScrollbarOpacityApp())
Loading