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

Fix clearing an OptionList #2567

Merged
merged 5 commits into from
May 16, 2023
Merged

Conversation

davep
Copy link
Contributor

@davep davep commented May 15, 2023

See #2557, credit to Will: #2557 (comment)

After a diversion into #2574 and #2582, with the obvious need to dive into the latter much deeper, we're going with this fix for the moment. I don't think it's the fix here, but it's for sure a fix that works for now and this should get a revisit if and when #2582 gets a deep dive.

Long story short: because of the nature of how Select works, most of the times that the content refresh happens the OptionList has no size. No size means it's impossible to calculate the content as the width is needed to know how many lines is needed for each prompt. The obvious fix here would be to add _on_show to OptionList and refresh the content, much like it does with _on_resize; however I'm not seeing the expected events happen when it's used within Select.

This fix delays the refresh until there is size for the widget, having the desired effect, albeit not in the most ideal way.

@davep davep self-assigned this May 15, 2023
@davep davep added bug Something isn't working Task labels May 15, 2023
@davep davep linked an issue May 15, 2023 that may be closed by this pull request
davep added 4 commits May 16, 2023 13:33
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.
@davep davep marked this pull request as ready for review May 16, 2023 13:45
Copy link
Contributor

@rodrigogiraoserrao rodrigogiraoserrao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's always amusing how a problem that created +2 related issues and that probably took you a long time to study just ends up with a temporary fix that is just 2 lines of code. 🤷

@davep davep linked an issue May 16, 2023 that may be closed by this pull request
@davep davep merged commit 83e4be7 into Textualize:main May 16, 2023
@davep davep deleted the issue/2557/select-update branch May 16, 2023 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

inconsistent behavior Select Widged
3 participants