-
Notifications
You must be signed in to change notification settings - Fork 950
Changing options of Select widget triggers Callback #2230
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
Comments
Thanks! As a dev note, I think we should special-case the code at https://github.com/jupyter-widgets/ipywidgets/blob/master/ipywidgets/widgets/widget_selection.py#L205-L212 so that if nothing is selected (as in the above code, where we explicitly set the value to None), we don't force a new selection. |
I'm currently running into this issue. I'm writing a file browser widget. As soon as I click a folder entry in the list it triggers the callback function that configures the options with the new folder contents (as expected). However, the first option is always being selected and triggers a callback, making the code go into a loop as long as the automatically selected entry is a folder. I'd be very interested in any potential workarounds until a more permanent solution is available. |
@crahan my workaround has been to utilize the .unobserve method before updating the options. s_w.unobserve(cb, 'value')
s_w.options = ['1','2','3']
s_w.observe(cb, 'value') |
@nickpollari that is awesome! Thank you so much. Everything's working as expected now. I added a
|
And a +awesome vote from me too for the @nickpollari 'widget unobserve' solution. I was seeing the same problem as @crahan for a RadioButton widget. Every time I updated the widget options I would get weird subtle bug behaviours due to the unexpected call-back trigger when the widget was updated. |
Adding to 8.0 to implement the suggestion above at #2230 (comment) . |
thanks @crahan @dreme and @jasongrout for the upcoming fix |
Should fix #3284 |
@jasongrout we should have a way to change the options of a Select widget without triggering the callback function. Whenever the options are changed for the widget the value attribute is automatically set which forces the callback to be triggered. See code below;
The text was updated successfully, but these errors were encountered: