Skip to content

Commit

Permalink
fix(input): add null to modelValue prop type declaration (#4297)
Browse files Browse the repository at this point in the history
* fix(input): add null to modelValue prop type declaration

* fix(input): do not convert 0 to empty string

---------

Co-authored-by: Maksim Nedoshev <m0ksem1337@gmail.com>
  • Loading branch information
untael and m0ksem committed Jun 3, 2024
1 parent 5f6bda5 commit b80e5ed
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/ui/src/components/va-input/VaInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
</template>

<script lang="ts">
import { computed, InputHTMLAttributes, nextTick, shallowRef, toRefs, useAttrs, useSlots, watch } from 'vue'
import { computed, InputHTMLAttributes, shallowRef, toRefs, useAttrs, useSlots, watch, PropType } from 'vue'
import omit from 'lodash/omit.js'
import pick from 'lodash/pick.js'
Expand Down Expand Up @@ -107,7 +107,7 @@ const props = defineProps({
// input
placeholder: { type: String, default: '' },
tabindex: { type: [String, Number], default: 0 },
modelValue: { type: [Number, String], default: '' },
modelValue: { type: [Number, String, null] as PropType<number | string | null>, default: '' },
type: { type: String as AnyStringPropType<'text' | 'password'>, default: 'text' },
inputClass: { type: String, default: '' },
pattern: { type: String },
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/components/va-input/hooks/useCleave.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const useCleaveProps = {
export const useCleave = (
element: Ref<HTMLInputElement | undefined>,
props: ExtractPropTypes<typeof useCleaveProps>,
syncValue: WritableComputedRef<string | number>,
syncValue: WritableComputedRef<string | number | null>,
) => {
const cleave = ref<Cleave>()

Expand Down Expand Up @@ -78,7 +78,7 @@ export const useCleave = (
}
}

return syncValue.value
return syncValue.value ?? ''
})

const onInput = (event: Event) => {
Expand Down

0 comments on commit b80e5ed

Please sign in to comment.