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

Fixes #3019.

Signed-off-by: David Tschida <dmtschida1@gmail.com>
pull/3026/head
David Tschida 2025-01-16 10:17:23 -08:00 committed by GitHub
parent a1ffc6c2ed
commit 8b4e6699c9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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