Skip to content

Commit

Permalink
Fix oh-stepper not working if step is an integer (#2109)
Browse files Browse the repository at this point in the history
Regression from #2090.

Fixes `Uncaught TypeError: Cannot read properties of undefined (reading
'length')` being thrown if the step property is an integer value, e.g. 1
or 1.0.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
(cherry picked from commit d4d7bea)
  • Loading branch information
florian-h05 committed Oct 8, 2023
1 parent 73333ec commit 762f746
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default {
// uses the number of decimals in the step config to round the provided number
if (!this.config.step) return value
const nbDecimals = Number(this.config.step).toString().replace(',', '.').split('.')[1]
return parseFloat(Number(value)).toFixed(nbDecimals.length)
return parseFloat(Number(value)).toFixed(nbDecimals ? nbDecimals.length : 0)
},
onChange (value) {
const applyOffset = (value) => (typeof this.config.offset === 'number') ? Number(this.toStepFixed(value - this.config.offset)) : value
Expand Down

0 comments on commit 762f746

Please sign in to comment.