Skip to content

Commit 3fcde21

Browse files
committed
Fix a regression in #1513 with creating selection range sliders.
The following was broken: from ipywidgets import SelectionRangeSlider s=SelectionRangeSlider(options=[1])
1 parent 587b1b6 commit 3fcde21

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

ipywidgets/widgets/widget_selection.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def _validate_options(self, proposal):
117117

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

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

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

418418
@observe('options')
419419
def _propagate_options(self, change):
420-
"Unselect any option"
420+
"Select the first range"
421+
options = self._options_full
422+
self.set_trait('_options_labels', tuple(i[0] for i in options))
423+
self._options_values = tuple(i[1] for i in options)
421424
if self._initializing_traits_ is not True:
422425
self.index = (0, 0)
423-
self.set_trait('_options_labels', tuple(i[0] for i in change.new))
424-
self._options_values = tuple(i[1] for i in change.new)
425426

426427
@validate('index')
427428
def _validate_index(self, proposal):

0 commit comments

Comments
 (0)