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
parent
3fbb0cbdfc
commit
aec6aaad39
|
@ -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