Better handling of empty state in numeric field.

This commit is contained in:
mateuswetah 2024-03-18 15:22:51 -03:00
parent cb5d643839
commit 59d5cd453a
1 changed files with 7 additions and 1 deletions

View File

@ -4,7 +4,7 @@
:ref="'tainacan-item-metadatum_id-' + itemMetadatum.metadatum.id + (itemMetadatum.parent_meta_id ? ('_parent_meta_id-' + itemMetadatum.parent_meta_id) : '')"
:disabled="disabled"
:placeholder="itemMetadatum.metadatum.placeholder ? itemMetadatum.metadatum.placeholder : ''"
:model-value="Number(value)"
:model-value="value === 0 || value ? Number(value) : null"
lang="en"
:min="getMin"
:max="getMax"
@ -52,6 +52,12 @@
if ( inputRef && !inputRef.checkHtml5Validity())
return;
// Allowing empty value as a state different of 0
if ( value === null || value === undefined || value === '' )
value = '';
else
value = Number(value);
this.$emit('update:value', value);
},
onBlur() {