Skip to content

Log widgets do not anchor as expected #6194

@tim-elmer

Description

@tim-elmer

Summary

When auto_scroll=False and anchor() are set on a Log or RichLog, the scrolling behavior is not as expected.

Expected Behavior

Based on the documentation for widget, the widget should anchor to the end of its contents unless the user has scrolled away.

I would assume that the widget would re-anchor itself if the user scrolls back to the end of the contents, but this is not described in the documentation.

Actual Behavior

The widget is anchored to the beginning of its contents. If the user scrolls away, the widget respects the scroll as expected. When the user scrolls back to the end of the contents, the widget again anchors to the beginning of its contents.

Screencast_20251025_151020.webm

Example

from datetime import datetime
from time import sleep

from textual import work
from textual.app import App
from textual.widgets import Log


class MyApp(App):
    def compose(self):
        yield Log(auto_scroll=False)

    def on_mount(self):
        self.log_widget = self.query_one(Log)
        self.log_widget.anchor()
        self.write_lines()

    @work(thread=True)
    def write_lines(self):
        while True:
            self.log_widget.write(str(datetime.now()) + "\n")
            sleep(1)

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

Textual Diagnostics

Versions

Name Value
Textual 6.4.0
Rich 14.2.0

Python

Name Value
Version 3.13.9
Implementation CPython
Compiler GCC 15.2.1 20250808 (Red Hat 15.2.1-1)
Executable /home/tim/.local/share/hatch/env/virtual/sweeper/91pWT2mp/sweeper/bin/python

Operating System

Name Value
System Linux
Release 6.17.4-200.fc42.x86_64
Version #1 SMP PREEMPT_DYNAMIC Sun Oct 19 18:47:49 UTC 2025

Terminal

Name Value
Terminal Application Konsole 250802
TERM xterm-256color
COLORTERM truecolor
FORCE_COLOR Not set
NO_COLOR Not set

Rich Console options

Name Value
size width=126, height=22
legacy_windows False
min_width 1
max_width 126
is_terminal True
encoding utf-8
max_height 22
justify None
overflow None
no_wrap False
highlight None
markup None
height None

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