diff --git a/CHANGELOG.md b/CHANGELOG.md index 618213a..7d1c3cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 2024-09-10 +- Debounce inputs for sliders to improve user experience while entering numbers + ## 2024-08-27 - Fixed a bug where sliders would pass decimal numbers to the API (e.g. UI shows 6 main characters but sends 5.6785) - Updated dependencies diff --git a/src/Filters.ts b/src/Filters.ts index f25a7f4..0d4d81f 100644 --- a/src/Filters.ts +++ b/src/Filters.ts @@ -870,14 +870,22 @@ class Filters extends EventTarget { } }) + let debouncer: number + minField.addEventListener('keyup', () => { + clearTimeout(debouncer) + debouncer = setTimeout(() => { container.noUiSlider.set([minField.value, null]) this.filterChangeCallback() + }, 500); }) maxField.addEventListener('keyup', () => { + clearTimeout(debouncer) + debouncer = setTimeout(() => { container.noUiSlider.set([null, maxField.value]) this.filterChangeCallback() + }, 500); }) }