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
parent
a1ffc6c2ed
commit
8b4e6699c9
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue