Skip to content

Fix a regression in #1513 with creating selection range sliders. #1514

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

Merged
merged 1 commit into from
Jul 18, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions ipywidgets/widgets/widget_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def _validate_options(self, proposal):

@observe('options')
def _propagate_options(self, change):
"Set the values and labels, and unselect any option if we aren't initializing"
"Set the values and labels, and select the first option if we aren't initializing"
options = self._options_full
self.set_trait('_options_labels', tuple(i[0] for i in options))
self._options_values = tuple(i[1] for i in options)
Expand Down Expand Up @@ -374,7 +374,7 @@ def _validate_options(self, proposal):
return proposal.value

class _MultipleSelectionNonempty(_MultipleSelection):
"""Selection that is guaranteed to have a value selected."""
"""Selection that is guaranteed to have an option available."""

def __init__(self, *args, **kwargs):
if len(kwargs.get('options', ())) == 0:
Expand Down Expand Up @@ -417,11 +417,12 @@ class SelectionRangeSlider(_MultipleSelectionNonempty):

@observe('options')
def _propagate_options(self, change):
"Unselect any option"
"Select the first range"
options = self._options_full
self.set_trait('_options_labels', tuple(i[0] for i in options))
self._options_values = tuple(i[1] for i in options)
if self._initializing_traits_ is not True:
self.index = (0, 0)
self.set_trait('_options_labels', tuple(i[0] for i in change.new))
self._options_values = tuple(i[1] for i in change.new)

@validate('index')
def _validate_index(self, proposal):
Expand Down