Skip to content

Inconsistent scrollbar location #5954

@davep

Description

@davep

Especially given the work that was done a wee while back to harmonise focus/cursor/etc look/feel across various widgets, I'm raising this as as "should this also be consistent too?" query.

Given this code:

from textual.app import App, ComposeResult
from textual.containers import VerticalScroll
from textual.widgets import TextArea, Tree, OptionList, Label

class ScrollBarLocationApp(App[None]):

    CSS = """
    Screen > * {
        width: 1fr;
        height: 1fr;
        border: none;
        background: $surface;
        &:focus {
            background: $panel;
        }
    }
    """

    def compose(self) -> ComposeResult:
        yield TextArea()
        yield Tree("")
        yield OptionList()
        yield VerticalScroll(id="scroller")

    def on_mount(self) -> None:
        self.query_one(TextArea).load_text("\n".join(f"This is line {n}" for n in range(1000)))
        self.query_one(Tree).root.expand()
        for n in range(1000):
            self.query_one(Tree).root.add(f"This is node {n}")
        self.query_one(OptionList).add_options(f"This is option {n}" for n in range(1000))
        self.query_one("#scroller").mount_all(
            Label(f"This is label {n}") for n in range(1000)
        )

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

we get this display:

Image

Out of the box I think folk would normally expect all of the scrollbars to line up. This can, of course, be fixed by tweaking the padding on the offending widgets, but perhaps it would make sense to have all widgets that can potentially add a scrollbar have them line up under most reasonable circumstances?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions