Skip to content

[BUG] Anchored container's scrollbar thumb is not repainted after the terminal gets shorter #6797

Open

Description

@Why-I-Game

A human user hit this bug in Textual v8.2.7. Claude Code (Sonnet 5.5 and Opus 5.5) wrote this report and the patch on their behalf. This post was reviewed and posted by the user, not automatically by AI. You may use the patch as-is under your project's licence, or base your own fix on any part of it; no attribution needed.

Have you checked closed issues? (https://github.com/Textualize/textual/issues?q=is%3Aissue+is%3Aclosed)

Yes, nothing found (see Related).

Have you checked against the most recent version of Textual? (https://pypi.org/search/?q=textual)

Yes: the code is unchanged on main (5e5b7ef).

The bug

When the terminal gets shorter, an anchored scrolling container (one pinned to its bottom, like a chat log) is scrolled to its new bottom, but its vertical scrollbar is not repainted. The thumb stays where it was drawn at the old size (short of the bottom) until something else repaints the bar, such as scrolling or hovering it. Seen in Toad 0.6.20, whose conversation is an anchored container.

To trigger

Run this, then make the terminal shorter (or run_test(size=(40, 30)), then pilot.resize_terminal(40, 15)):

from textual.app import App, ComposeResult
from textual.containers import VerticalScroll
from textual.widgets import Static


class AnchoredApp(App):
    def compose(self) -> ComposeResult:
        with VerticalScroll():
            for n in range(100):
                yield Static(f"Line {n}")

    def on_mount(self) -> None:
        self.query_one(VerticalScroll).anchor()


if __name__ == "__main__":
    AnchoredApp().run()
  • Expected: the thumb is at the bottom of the bar, as when the app starts at the smaller size.
  • Actual: at 40 x 30 resized to 40 x 15, the thumb is drawn on rows 11 to 13 of 15 instead of 13 to 15, and stays there (checked after 1 s).

Cause

Compositor._arrange_root (src/textual/_compositor.py) moves an anchored container to its new end by setting scroll_y, scroll_target_y and the scrollbar's _reactive_position directly, with no watcher. Nothing asks the scrollbar to repaint, and its screen region is unchanged, so the compositor keeps the old thumb.

Fix

Refresh the scrollbar when that move changes its position (plus a regression test):
Why-I-Game/textual-ai-bugfixes@main...fix-anchor-scrollbar-after-resize

How it was tested

The regression test compares the scrollbar column after the resize with a fresh start at the final size: it fails before the fix and passes after. The Markdown, compositor and widget tests, and the snapshot tests matching "anchor" or "scroll", pass. The fix has been in daily use in a patched Toad install.

Related

Textual 8.2.7, Python 3.14.4, Linux.

Activity

  1. github-actions commented on Nov 18, 2026

    @github-actions

    We found the following entries in the FAQ which you may find helpful:

    Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review.

    This project is developed and maintained by Will McGugan. Consider sponsoring Will's work on this project (and others).

    This is an automated reply, generated by FAQtory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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