Skip to content

Scroll behavior of RichLog and Log differ #6311

@gzzi

Description

@gzzi

The bug

The vertical scroll is not behaving the same between RichLog and Log. Both have auto_scroll to True by default. On a Log widget, the user can scroll up and the content stay at this place even if new line are written. On RichLog, the content goes back to the end when a new line is written.

It's similar to #6194 except that I don't use thread or anchor.

Example

from datetime import datetime

from textual.app import App, ComposeResult
from textual.widgets import Log, RichLog


class ExampleApp(App):
    def compose(self) -> ComposeResult:
        yield Log()
        yield RichLog()

    def on_mount(self) -> None:
        self.set_interval(1.0, self.write_line)

    def write_line(self) -> None:
        log = self.query_one(Log)
        log.write_line(str(datetime.now()) + ' normal')
        rich_log = self.query_one(RichLog)
        rich_log.write(str(datetime.now()) + ' rich')


if __name__ == '__main__':
    app = ExampleApp()
    app.run()

Image

Textual Diagnostics

Versions

Name Value
Textual 7.0.0
Rich 14.2.0

Python

Name Value
Version 3.12.3
Implementation CPython
Compiler GCC 13.3.0
Executable /apollo/apollo/.venv/bin/python3

Operating System

Name Value
System Linux
Release 6.6.87.2-microsoft-standard-WSL2
Version #1 SMP PREEMPT_DYNAMIC Thu Jun 5 18:30:46 UTC 2025

Terminal

Name Value
Terminal Application vscode (1.107.0)
TERM xterm-256color
COLORTERM truecolor
FORCE_COLOR Not set
NO_COLOR Not set

Rich Console options

Name Value
size width=334, height=38
legacy_windows False
min_width 1
max_width 334
is_terminal True
encoding utf-8
max_height 38
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