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

Hold sync during set_state + fix selection widgets flakiness #3271

Merged
merged 6 commits into from
Oct 26, 2021

Conversation

vidartf
Copy link
Member

@vidartf vidartf commented Sep 8, 2021

Open question: All update events will be passed the options argument by backbone, if given. Currently we do not reflect this in our base classes unless we use it. Are we happy with this, or do we want to add that? Adding it could lead to typing noise for third-party widgets which implement their own update function, and JS is happy to discard superfluous arguments to a function.

In these tests, the "order 2" assertion will fail, since backbone processes the state using "for (key in attrs)", which means declaration order in most browsers (unofficial standard). Here our code will:
- Process the change:index event, setting the index to 1, which will not work, since it at that time will be 0 options in the listbox.
- Process the change:_options_labels, adding the 3 options, but keeping the -1 index.
Use the update event (which is called from "change" event), instead of relying on the individual change:key events. This way, we can handle both options and index being set at once.
@github-actions
Copy link

github-actions bot commented Sep 8, 2021

Binder 👈 Launch a binder notebook on branch vidartf/ipywidgets/sync-set-state

Updated to reflect change in behavior.
@martinRenou
Copy link
Member

martinRenou commented Sep 20, 2021

@maartenbreddels for awareness. Background in #2256 and #2259

Copy link
Member

@martinRenou martinRenou left a comment

Choose a reason for hiding this comment

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

LGTM

@martinRenou martinRenou merged commit 51cb73a into jupyter-widgets:master Oct 26, 2021
@vidartf vidartf deleted the sync-set-state branch October 26, 2021 16:45
jasongrout added a commit to jasongrout/ipywidgets that referenced this pull request Mar 2, 2022
We have to explicitly use hold_sync in the test, since jupyter-widgets#3271 was targeted to 8.0 and not backported to 7.x.
jasongrout added a commit to jasongrout/ipywidgets that referenced this pull request Mar 2, 2022
We have to explicitly use hold_sync in the test, since jupyter-widgets#3271 was targeted to 8.0 and not backported to 7.x.
maartenbreddels added a commit to maartenbreddels/ipywidgets that referenced this pull request Nov 29, 2022
If we do, we get very inconsistent behaviour, see jupyter-widgets#3635 for more
details and jupyter-widgets#3271 for the reasons to implement this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hold sync during set_state?
2 participants