From e977fa063930a5fe3ec817390e9077c43c7e3712 Mon Sep 17 00:00:00 2001 From: petar-qb Date: Tue, 14 Nov 2023 09:44:35 +0100 Subject: [PATCH 1/3] Fix vm.Slider and vm.RangeSlider to work with incorrect textual input --- vizro-core/src/vizro/static/js/models/range_slider.js | 3 +++ vizro-core/src/vizro/static/js/models/slider.js | 3 +++ 2 files changed, 6 insertions(+) diff --git a/vizro-core/src/vizro/static/js/models/range_slider.js b/vizro-core/src/vizro/static/js/models/range_slider.js index fe45382ec..94e877368 100644 --- a/vizro-core/src/vizro/static/js/models/range_slider.js +++ b/vizro-core/src/vizro/static/js/models/range_slider.js @@ -21,6 +21,9 @@ export function _update_range_slider_values( trigger_id === `${self_data["id"]}_start_value` || trigger_id === `${self_data["id"]}_end_value` ) { + if (isNaN(start) || isNaN(end)) { + return dash_clientside.no_update; + } [start_text_value, end_text_value] = [start, end]; } else if (trigger_id === self_data["id"]) { [start_text_value, end_text_value] = [slider[0], slider[1]]; diff --git a/vizro-core/src/vizro/static/js/models/slider.js b/vizro-core/src/vizro/static/js/models/slider.js index 3dffc3c0f..d467706b5 100644 --- a/vizro-core/src/vizro/static/js/models/slider.js +++ b/vizro-core/src/vizro/static/js/models/slider.js @@ -7,6 +7,9 @@ export function _update_slider_values(start, slider, input_store, self_data) { dash_clientside.callback_context.triggered[0]["prop_id"].split(".")[0]; } if (trigger_id === `${self_data["id"]}_text_value`) { + if (isNaN(start)) { + return dash_clientside.no_update; + } text_value = start; } else if (trigger_id === self_data["id"]) { text_value = slider; From 6258de517a1e466cb815d5e3fa052266f564ecd6 Mon Sep 17 00:00:00 2001 From: petar-qb Date: Tue, 14 Nov 2023 10:02:14 +0100 Subject: [PATCH 2/3] A Changelog file added. --- ...tar_pejovic_fix_sliders_incorrect_input.md | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 vizro-core/changelog.d/20231114_095856_petar_pejovic_fix_sliders_incorrect_input.md diff --git a/vizro-core/changelog.d/20231114_095856_petar_pejovic_fix_sliders_incorrect_input.md b/vizro-core/changelog.d/20231114_095856_petar_pejovic_fix_sliders_incorrect_input.md new file mode 100644 index 000000000..ec716083f --- /dev/null +++ b/vizro-core/changelog.d/20231114_095856_petar_pejovic_fix_sliders_incorrect_input.md @@ -0,0 +1,46 @@ + + + + + + + +### Fixed + +- Fixed `vm.Slider` and `vm.RangeSlider` to work with incorrect text input. ([#173](https://github.com/mckinsey/vizro/pull/173)) + + From b8ba39c2bd0c832beadcfb15adc180087f5dabcb Mon Sep 17 00:00:00 2001 From: petar-qb Date: Tue, 14 Nov 2023 10:36:50 +0100 Subject: [PATCH 3/3] Small linting fix --- .../20231114_095856_petar_pejovic_fix_sliders_incorrect_input.md | 1 + 1 file changed, 1 insertion(+) diff --git a/vizro-core/changelog.d/20231114_095856_petar_pejovic_fix_sliders_incorrect_input.md b/vizro-core/changelog.d/20231114_095856_petar_pejovic_fix_sliders_incorrect_input.md index ec716083f..f0518fa2d 100644 --- a/vizro-core/changelog.d/20231114_095856_petar_pejovic_fix_sliders_incorrect_input.md +++ b/vizro-core/changelog.d/20231114_095856_petar_pejovic_fix_sliders_incorrect_input.md @@ -34,6 +34,7 @@ Uncomment the section that is right (remove the HTML comment wrapper). - A bullet item for the Deprecated category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1)) --> + ### Fixed - Fixed `vm.Slider` and `vm.RangeSlider` to work with incorrect text input. ([#173](https://github.com/mckinsey/vizro/pull/173))