oh-slider: Fix handing of steps with many decimals when rounding state values (#3022)

Fixes #3019.

Signed-off-by: David Tschida <dmtschida1@gmail.com>
(cherry picked from commit 8b4e6699c9)
4.3.x
David Tschida 2025-01-16 10:17:23 -08:00 committed by Florian Hotze
parent 3fbb0cbdfc
commit aec6aaad39
1 changed files with 2 additions and 2 deletions

View File

@ -55,8 +55,8 @@ export default {
},
toStepFixed (value) {
// uses the number of decimals in the step config to round the provided number
const nbDecimals = this.config.step ? Number(this.config.step).toString().replace(',', '.').split('.')[1] : 0
return parseFloat(Number(value).toFixed(nbDecimals))
const nbDecimals = this.config.step ? Number(this.config.step).toString().replace(',', '.').split('.')[1]?.length : 0
return parseFloat(Number(value).toFixed(nbDecimals ?? 0))
},
onChange (newValue) {
if (isNaN(this.value)) return