Skip to content

scroll_end off by one #1215

@aaronst

Description

@aaronst

It looks like Widget.scroll_end() is off by one line. Here's an app to reproduce:

from textual.app import App, ComposeResult
from textual.widgets import DataTable, Footer


class Test(App):
    BINDINGS = [("a", "add_row", "Add a row")]
    DEFAULT_CSS = """
    DataTable {
        height: 5;
    }
    """

    def compose(self) -> ComposeResult:
        rows = (
            ("1", "one"),
            ("2", "two"),
            ("3", "three"),
            ("4", "four"),
            ("5", "five"),
        )

        self.table = DataTable()
        self.table.add_columns("#", "number")
        self.table.add_rows(rows)

        yield self.table
        yield Footer()

    def action_add_row(self) -> None:
        self.table.add_row("6", "six")
        self.table.scroll_end()


Test().run()

After adding the sixth row, the DataTable scrolls to the fifth row.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions