Skip to content

ListView's highlight vanishes after clear and extend #6300

@fdw

Description

@fdw

The bug

I have a ListView that shows items based on a reactive field. It does update its items correctly. However, after changing its items (with clear() and extend()) and setting an index, there is no highlight. The selection seems to be correct, but I can only see it after interacting with the list.

Code example:

    def watch_items(self, things) -> None:
        list = self.query_one("#listview", ListView)
        index = list.index or 0

        with self.app.batch_update():
            list.clear()
            list.extend([ListItem(Label(it.name)) for it in things])

It will be helpful if you run the following command and paste the results:

# Textual Diagnostics

## Versions

| Name    | Value  |
|---------|--------|
| Textual | 6.11.0 |
| Rich    | 14.2.0 |

## Python

| Name           | Value                                              |
|----------------|----------------------------------------------------|
| Version        | 3.13.5                                             |
| Implementation | CPython                                            |
| Compiler       | Clang 20.1.4                                       |
| Executable     | /home/fdw/Code/podcast_migration/.venv/bin/python3 |

## Operating System

| Name    | Value                                                  |
|---------|--------------------------------------------------------|
| System  | Linux                                                  |
| Release | 6.18.2-1-MANJARO                                       |
| Version | #1 SMP PREEMPT_DYNAMIC Thu, 18 Dec 2025 13:50:16 +0000 |

## Terminal

| Name                 | Value       |
|----------------------|-------------|
| Terminal Application | Kitty       |
| TERM                 | xterm-kitty |
| COLORTERM            | truecolor   |
| FORCE_COLOR          | *Not set*   |
| NO_COLOR             | *Not set*   |

## Rich Console options

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