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

Can't scroll vertically programmatically within a DataTable #2458

Closed
rodrigogiraoserrao opened this issue May 2, 2023 · 1 comment · Fixed by #2466
Closed

Can't scroll vertically programmatically within a DataTable #2458

rodrigogiraoserrao opened this issue May 2, 2023 · 1 comment · Fixed by #2466
Assignees
Labels
bug Something isn't working Task

Comments

@rodrigogiraoserrao
Copy link
Contributor

Run the app below and press E. It should scroll to the end.

Run the app below and press J and then S. It should scroll to the row with the number 100.

Looking at Widget.scroll_to_region, the method concludes that the cell in question is already visible (delta_x and delta_y from Region.get_scroll_to_visible are both 0).

from textual.app import App, ComposeResult
from textual.coordinate import Coordinate
from textual.widgets import DataTable


class TableApp(App):
    def compose(self) -> ComposeResult:
        yield DataTable()

    def on_mount(self) -> None:
        table = self.query_one(DataTable)
        table.cursor_type = "cell"
        table.zebra_stripes = True
        table.add_column("n")
        table.add_rows([(n,) for n in range(300)])

    def key_c(self):
        table = self.query_one(DataTable)
        table.cursor_type = next(cursors)

    def key_j(self):
        table = self.query_one(DataTable)
        table.cursor_coordinate = Coordinate(100, 0)

    def key_s(self):
        self.query_one(DataTable)._scroll_cursor_into_view()

    def key_e(self):
        self.query_one(DataTable).action_scroll_end()


app = TableApp()
if __name__ == "__main__":
    app.run()
@rodrigogiraoserrao rodrigogiraoserrao changed the title Can't scroll vertically within a DataTable Can't scroll vertically programmatically within a DataTable May 2, 2023
@rodrigogiraoserrao rodrigogiraoserrao added bug Something isn't working Task labels May 2, 2023
@rodrigogiraoserrao rodrigogiraoserrao self-assigned this May 2, 2023
rodrigogiraoserrao added a commit that referenced this issue May 3, 2023
rodrigogiraoserrao added a commit that referenced this issue May 4, 2023
@github-actions
Copy link

github-actions bot commented May 4, 2023

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

rodrigogiraoserrao added a commit that referenced this issue May 4, 2023
* Add FAQ about DataTable scrolling.

Related issues: #2458

* Write concisely.

* Update questions/datatable-doesnt-scroll.question.md

Co-authored-by: Will McGugan <willmcgugan@gmail.com>

* Remove example.

* Add recommendation.

---------

Co-authored-by: Will McGugan <willmcgugan@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Task
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant