Skip to content

fixt the Scrolling back to the bottom does not restore anchored scroll - #6683

Open
prabinKh wants to merge 1 commit into
Textualize:mainfrom
prabinKh:fix/#6677
Open

fixt the Scrolling back to the bottom does not restore anchored scroll#6683
prabinKh wants to merge 1 commit into
Textualize:mainfrom
prabinKh:fix/#6677

Conversation

@prabinKh

@prabinKh prabinKh commented Aug 5, 2026

Copy link
Copy Markdown
  1. Smarter anchor handling during scroll (widget.py)

Added _handle_scroll_anchor() and use it in scroll_to / _scroll_to instead of unconditionally calling release_anchor():

Release the anchor only when scrolling away from the bottom.
Re-engage the anchor when the scroll target reaches the bottom (target_y >= max_scroll_y).
2. More reliable anchor check (widget.py)

Updated _check_anchor() to use is_vertical_scroll_end instead of a raw scroll_y >= max_scroll_y comparison.

  1. Re-check anchor during layout (_compositor.py)

During layout, if a widget is anchored but released and scroll_y is still at the bottom edge, re-engage the anchor before applying bottom-gluing. This handles the case where content grows while the user is already at the bottom.

Test plan
Added tests/test_anchor_scroll.py with 4 tests:
Anchored widget follows new content
Scrolling up releases the anchor
Scrolling back to bottom re-engages the anchor
Anchor stays engaged while content streams after restore
Ran pytest tests/test_anchor_scroll.py -v — all 4 passed
Ran pytest tests/test_compositor.py tests/test_containers.py — no regressions
Files changed
src/textual/widget.py — anchor release/restore logic during scroll
src/textual/_compositor.py — re-check anchor during layout
tests/test_anchor_scroll.py — new test coverage

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

Successfully merging this pull request may close these issues.

1 participant