-
Notifications
You must be signed in to change notification settings - Fork 780
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
inconsistent behavior Select Widged #2557
Comments
@davep Suspect this is an issue with |
The following diff fixes it. AFAICT.
If this is the fix, it just needs tests. |
See Textualize#2557, credit to Will: Textualize#2557 (comment)
Yup, looks good here. |
@rodrigogiraoserrao I think Dave is doing this. |
While looking at adding some useful testing for this, I've realised that the suggested fix, while it works, is slightly puzzling. The change sets up a call to |
Tracing it through so far, I'm starting to suspect it's tied in with the use of If I'm reading things correctly the An alternative fix (that I'm not proposing, just making a note of to explain things), would be this: diff --git a/src/textual/widgets/_select.py b/src/textual/widgets/_select.py
index 25564af9..b9b5d0d4 100644
--- a/src/textual/widgets/_select.py
+++ b/src/textual/widgets/_select.py
@@ -329,6 +329,7 @@ class Select(Generic[SelectType], Vertical, can_focus=True):
overlay = self.query_one(SelectOverlay)
self.set_class(expanded, "-expanded")
if expanded:
+ overlay._refresh_content_tracking(force=True)
overlay.focus()
if self.value is None:
overlay.select(None) by this time the widget has |
You could compare what happens if you remove |
@willmcgugan Good call! Okay, it's not that. And now I look at it it's possibly more obvious: I suspect the problem is that the clear/add is happening while it's |
Makes me wonder if what's needed here (likely needed anyway) is a self._request_content_tracking_refresh() much like how |
Not directly related, but while trying to work out why the |
While the fix for Textualize#2557 likely isn't *the* fix (see Textualize#2582 for some context around that), it is a fix that works for now. As such, with the change, there was a double attempt to refresh the content tracking in the clearing of options in the OptionList, which shouldn't be necessary. This removes that.
This helps test the practical impact of the fix added for Textualize#2557.
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
Getting very inconsistent behavior with the new Select Widged when using their .set_options. Often after the options stay empty, depending on if the Select was used before, an item was selected before or not, or the options before where empy ([]).
Keep the great work up!
The text was updated successfully, but these errors were encountered: