Skip to content

Mouse hover highlighting of a ListItem in a ListView works in unexpected ways #3030

Closed
@davep

Description

@davep

Given this code:

from textual.app import App, ComposeResult
from textual.containers import Horizontal
from textual.widgets import ListView, ListItem, Label

class ListViewHoverIssueApp(App[None]):

    def compose(self) -> ComposeResult:
        yield ListView(
            *[ListItem(Horizontal(Label(f"Item {n}"))) for n in range(100)]
        )

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

note that the :hover highlight only appears when the mouse is hovered over the "empty" part of the item in the list, not when over the text. The reason would seem to be:

    ListItem > Widget :hover {
        background: $boost;
    }

in the code for ListItem; which means that the background boost only happens when (in the case of the example code above) the mouse is over the Horizontal, but not when it's over the Label.

Metadata

Metadata

Assignees

No one assigned

    Labels

    TaskbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions