Skip to content

Bug with validate_highlighted after empty OptionList? #3560

@TomJGooding

Description

@TomJGooding

This follows on from discussion #3559 about confusing errors when trying to remove options from a SelectionList.

It looks like parent OptionList widget was designed to always have a highlighted option based on the validation?

def validate_highlighted(self, highlighted: int | None) -> int | None:
"""Validate the `highlighted` property value on access."""
if not self._options:
return None
if highlighted is None or highlighted < 0:
return 0

But if you start with an empty OptionList and then add options later, the highlighted reactive is still None which suggests this validation must not be called.

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