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..f0518fa2d --- /dev/null +++ b/vizro-core/changelog.d/20231114_095856_petar_pejovic_fix_sliders_incorrect_input.md @@ -0,0 +1,47 @@ + + + + + + + + +### Fixed + +- Fixed `vm.Slider` and `vm.RangeSlider` to work with incorrect text input. ([#173](https://github.com/mckinsey/vizro/pull/173)) + + 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;