Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug with validate_highlighted after empty OptionList? #3560

Closed
TomJGooding opened this issue Oct 19, 2023 · 5 comments
Closed

Bug with validate_highlighted after empty OptionList? #3560

TomJGooding opened this issue Oct 19, 2023 · 5 comments

Comments

@TomJGooding
Copy link
Contributor

TomJGooding commented Oct 19, 2023

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.

@github-actions
Copy link

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

@TomJGooding TomJGooding changed the title Bug with OptionList validate_highlighted? Bug with validate_highlighted after empty OptionList? Oct 19, 2023
@TomJGooding
Copy link
Contributor Author

TomJGooding commented Oct 19, 2023

If I'm right that OptionList is designed to always have a highlighted option, this might actually cause issues with the CommandPalette?

@davep
Copy link
Contributor

davep commented Nov 21, 2023

My recollection is that the intended design is that it retains a highlight once there is a highlight

@TomJGooding
Copy link
Contributor Author

My memory is a little hazy on this issue but I think this is now fixed, likely as part of #3912. Closing.

Copy link

github-actions bot commented Feb 7, 2024

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants