Skip to content

Commit

Permalink
fix(counter): floatify value
Browse files Browse the repository at this point in the history
  • Loading branch information
m0ksem committed Apr 1, 2024
1 parent 2e43fc0 commit 4d1e178
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/ui/src/components/va-counter/VaCounter.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ export const Step: StoryFn = () => ({
stateful
:step="2"
/>
<VaCounter
stateful
:step="0.1"
/>
`,
})

Expand Down
11 changes: 10 additions & 1 deletion packages/ui/src/components/va-counter/VaCounter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,16 @@ const {
blur,
} = useFocus(input, emit)
const { valueComputed } = useStateful(props, emit)
const { valueComputed: statefulValue } = useStateful(props, emit)
function floatify (num: number | string) {
return parseFloat(Number(num).toFixed(10))
}
const valueComputed = computed({
get () { return statefulValue.value },
set (v) { statefulValue.value = floatify(v) },
})
const reset = () => withoutValidation(() => {
emit('update:modelValue', props.clearValue)
Expand Down

0 comments on commit 4d1e178

Please sign in to comment.