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

Scrollbar background styling not initially applied (since 0.89) #5626

Open
davep opened this issue Mar 8, 2025 · 1 comment
Open

Scrollbar background styling not initially applied (since 0.89) #5626

davep opened this issue Mar 8, 2025 · 1 comment

Comments

@davep
Copy link
Contributor

davep commented Mar 8, 2025

Given this code:

from textual.app import App, ComposeResult
from textual.widgets import OptionList

class BorkedScrollBarBackgroundApp(App[None]):

    CSS = """
    *:focus {
        scrollbar-background: red;
    }
    """

    def compose(self) -> ComposeResult:
        yield OptionList(*(f"This is option {n}" for n in range(1000)))

if __name__ == "__main__":
    BorkedScrollBarBackgroundApp().run()

the expectation would be that the scrollbar's background would be red once the application has run up. This is the case up to Textual v0.88.

Starting with v0.89 the background is the initial styling and only catches up if you do something that causes a refresh (resize the terminal, move he mouse over the scrollbar, that sort of thing).

@TomJGooding
Copy link
Contributor

I thought this might be easy to bisect, but unfortunately it looks like this only worked for the OptionList in v0.88.0.

from textual.app import App, ComposeResult
from textual.widgets import DataTable, Label, ListItem, ListView, OptionList, TextArea


class BorkedScrollBarBackgroundApp(App[None]):
    CSS = """
    *:focus {
        scrollbar-background: red;
    }

    OptionList, ListView, DataTable, TextArea {
        height: 1fr;
    }
    """

    # Try changing the widget that has initial focus
    AUTO_FOCUS = "OptionList"

    def compose(self) -> ComposeResult:
        yield OptionList(*(f"This is option {n}" for n in range(250)))
        yield ListView(*(ListItem(Label(f"This is list item {n}")) for n in range(250)))
        yield DataTable()
        yield TextArea("\n".join((f"This is line {n}") for n in range(250)))

    def on_mount(self) -> None:
        table = self.query_one(DataTable)
        table.add_column("Column")
        for n in range(250):
            table.add_row(f"This is row {n}")


if __name__ == "__main__":
    BorkedScrollBarBackgroundApp().run()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants