From 59d5cd453acc0246a12619ee8d9bf8b7b0513e9e Mon Sep 17 00:00:00 2001 From: mateuswetah Date: Mon, 18 Mar 2024 15:22:51 -0300 Subject: [PATCH] Better handling of empty state in numeric field. --- .../components/metadata-types/numeric/TainacanNumeric.vue | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/views/admin/components/metadata-types/numeric/TainacanNumeric.vue b/src/views/admin/components/metadata-types/numeric/TainacanNumeric.vue index c520a92ea..1f95785ee 100644 --- a/src/views/admin/components/metadata-types/numeric/TainacanNumeric.vue +++ b/src/views/admin/components/metadata-types/numeric/TainacanNumeric.vue @@ -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" @@ -51,6 +51,12 @@ const inputRef = this.$refs['tainacan-item-metadatum_id-' + this.itemMetadatum.metadatum.id + (this.itemMetadatum.parent_meta_id ? ('_parent_meta_id-' + this.itemMetadatum.parent_meta_id) : '')]; 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); },