From 00b8150f3e8b8be6d6864c22c000c7a753b7aaa2 Mon Sep 17 00:00:00 2001 From: Cory LaViska Date: Tue, 16 Dec 2025 11:06:27 -0500 Subject: [PATCH] ensure min/max/step are numbers; fixes #1823 (#1832) Co-authored-by: konnorrogers --- packages/webawesome/docs/docs/resources/changelog.md | 1 + packages/webawesome/src/components/slider/slider.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/webawesome/docs/docs/resources/changelog.md b/packages/webawesome/docs/docs/resources/changelog.md index 0e2eb6ef7..ae2a2a9d1 100644 --- a/packages/webawesome/docs/docs/resources/changelog.md +++ b/packages/webawesome/docs/docs/resources/changelog.md @@ -27,6 +27,7 @@ Components with the Experimental badge sh - Fixed a bug in `` that prevented clicks on the tag's remove button from removing options in multiple mode - Fixed a bug in `` that caused tags to appear in alphabetical order instead of selection order when using `multiple` - Improved performance of `` so initial rendering occurs faster, especially with multiple icons on the page [issue:1729] +- Improved `` to not throw an error when string values are passed to the `min`, `max`, and `step` properties [issue:1823] - Fixed a bug in Web Awesome form controls that caused `` to set the form property to equal `"foo"` instead of returning an `HTMLFormElement` breaking platform expectations. [pr:1815] - Fixed a bug in `` causing it to not copy over attributes for form submissions. [pr:1815] - Improved performance of all components by fixing how CSS is imported and reused [issue:1812] diff --git a/packages/webawesome/src/components/slider/slider.ts b/packages/webawesome/src/components/slider/slider.ts index e896e6174..dab5b6eb7 100644 --- a/packages/webawesome/src/components/slider/slider.ts +++ b/packages/webawesome/src/components/slider/slider.ts @@ -431,8 +431,14 @@ export default class WaSlider extends WebAwesomeFormAssociatedElement { /** Clamps a number to min/max while ensuring it's a valid step interval. */ private clampAndRoundToStep(value: number) { const stepPrecision = (String(this.step).split('.')[1] || '').replace(/0+$/g, '').length; - value = Math.round(value / this.step) * this.step; - value = clamp(value, this.min, this.max); + + // Ensure we're working with numbers (in case the user passes strings to the respective properties) + const step = Number(this.step); + const min = Number(this.min); + const max = Number(this.max); + + value = Math.round(value / step) * step; + value = clamp(value, min, max); return parseFloat(value.toFixed(stepPrecision)); }