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

Implement disabled parameter for editable sliders #5319

Merged
merged 2 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Version 1.2.1

Date: 2023-07-24
Date: 2023-07-25

This micro-release focuses on a small number of enhancements and rendering related bug fixes. Specifically it adds support for notifying users when the page is ready and when the Websocket disconnects using corresponding config options and upgrades the Vizzu version, thereby adding support for tooltips and enabling animations when the data is updated. The bug fixes are primarily focused on ensuring components such as `GridStack` and `Tabulator` render correctly and do not unnecessarily re-render or reload stylesheets. Many thanks and welcome to @owenlamont, @sciemon, @DGLaurits, @Ciemarr and @Kislovskiy for their first contributions to Panel and the maintainers @MarcSkovMadsen, @Hoxbro and @philippjfr for contributing to this release.

Expand All @@ -22,6 +22,7 @@ This micro-release focuses on a small number of enhancements and rendering relat
- Treat `Tabulator` `row_contents` as real children ensuring layout behaves correctly ([#5292](https://github.com/holoviz/panel/pull/5292))
- Fix `Video` `min_height` and `max_height` ([#5296](https://github.com/holoviz/panel/pull/5296))
- Make `TextEditor` invisible until CSS is loaded ([#5297](https://github.com/holoviz/panel/pull/5297))
- Fix `disabled` parameter on editable sliders ([#5319]((https://github.com/holoviz/panel/pull/5319))

### Compatibility

Expand Down
3 changes: 2 additions & 1 deletion doc/about/releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ See [the HoloViz blog](https://blog.holoviz.org/tag/panel.html) for a visual sum

## Version 1.2.1

Date: 2023-07-24
Date: 2023-07-25

This micro-release focuses on a small number of enhancements and rendering related bug fixes. Specifically it adds support for notifying users when the page is ready and when the Websocket disconnects using corresponding config options and upgrades the Vizzu version, thereby adding support for tooltips and enabling animations when the data is updated. The bug fixes are primarily focused on ensuring components such as `GridStack` and `Tabulator` render correctly and do not unnecessarily re-render or reload stylesheets. Many thanks and welcome to @owenlamont, @sciemon, @DGLaurits, @Ciemarr and @Kislovskiy for their first contributions to Panel and the maintainers @MarcSkovMadsen, @Hoxbro and @philippjfr for contributing to this release.

Expand All @@ -24,6 +24,7 @@ This micro-release focuses on a small number of enhancements and rendering relat
- Treat `Tabulator` `row_contents` as real children ensuring layout behaves correctly ([#5292](https://github.com/holoviz/panel/pull/5292))
- Fix `Video` `min_height` and `max_height` ([#5296](https://github.com/holoviz/panel/pull/5296))
- Make `TextEditor` invisible until CSS is loaded ([#5297](https://github.com/holoviz/panel/pull/5297))
- Fix `disabled` parameter on editable sliders ([#5319]((https://github.com/holoviz/panel/pull/5319))

### Compatibility

Expand Down
23 changes: 22 additions & 1 deletion panel/tests/widgets/test_slider.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,6 @@ def test_discrete_slider_options_dict(document, comm):
discrete_slider.value = options['1']
assert widget.value == 1


@pytest.mark.parametrize(
'editableslider,start,end,step,val1,val2,val3,diff1',
[
Expand Down Expand Up @@ -476,6 +475,16 @@ def test_editable_slider(document, comm,
assert slider._slider.end == slider.fixed_end == slider_widget.end
slider.fixed_end = None

def test_editable_slider_disabled():
slider = EditableFloatSlider(disabled=True)

assert slider._slider.disabled
assert slider._value_edit.disabled

slider.disabled = False

assert not slider._slider.disabled
assert not slider._value_edit.disabled

@pytest.mark.parametrize(
'editableslider,start,end,step,val1,val2,val3,diff1',
Expand Down Expand Up @@ -545,6 +554,18 @@ def test_editable_rangeslider(document, comm,
assert slider._slider.end == slider.fixed_end == slider_widget.end
slider.fixed_end = None

def test_editable_range_slider_disabled():
slider = EditableRangeSlider(disabled=True)

assert slider._slider.disabled
assert slider._start_edit.disabled
assert slider._end_edit.disabled

slider.disabled = False

assert not slider._slider.disabled
assert not slider._start_edit.disabled
assert not slider._end_edit.disabled

@pytest.mark.parametrize(
"editableslider",
Expand Down
20 changes: 15 additions & 5 deletions panel/widgets/slider.py
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,7 @@ def __init__(self, **params):

label = Row(self._label, self._value_edit)
self._composite.extend([label, self._slider])
self._update_disabled()
self._update_editable()
self._update_layout()
self._update_name()
Expand Down Expand Up @@ -860,9 +861,13 @@ def _update_layout(self):
w = (self.width or 300)//4
self._value_edit.width = w

@param.depends('editable', watch=True)
@param.depends('disabled', 'editable', watch=True)
def _update_editable(self):
self._value_edit.disabled = not self.editable
self._value_edit.disabled = (not self.editable) or self.disabled

@param.depends('disabled', watch=True)
def _update_disabled(self):
self._slider.disabled = self.disabled

@param.depends('name', watch=True)
def _update_name(self):
Expand Down Expand Up @@ -1062,6 +1067,7 @@ def __init__(self, **params):
}
""")
self._update_editable()
self._update_disabled()
self._update_layout()
self._update_name()
self._update_slider()
Expand Down Expand Up @@ -1104,10 +1110,14 @@ def _validate_init_bounds(self, params):
start = params.get("start", end - params.get("step", 1))
params["value"] = (start, end)

@param.depends('editable', watch=True)
@param.depends('disabled', watch=True)
def _update_disabled(self):
self._slider.disabled = self.disabled

@param.depends('disabled', 'editable', watch=True)
def _update_editable(self):
self._start_edit.disabled = not self.editable[0]
self._end_edit.disabled = not self.editable[1]
self._start_edit.disabled = (not self.editable[0]) or self.disabled
self._end_edit.disabled = (not self.editable[1]) or self.disabled

@param.depends('name', watch=True)
def _update_name(self):
Expand Down