Browse Source

fix(gui): treat empty string as null for number fields

re #4701

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/4715/head
Pranav C 2 years ago
parent
commit
d395d643bb
  1. 13
      packages/nc-gui/components/cell/Decimal.vue
  2. 13
      packages/nc-gui/components/cell/Float.vue
  3. 13
      packages/nc-gui/components/cell/Integer.vue

13
packages/nc-gui/components/cell/Decimal.vue

@ -16,7 +16,18 @@ const emits = defineEmits<Emits>()
const editEnabled = inject(EditModeInj)
const vModel = useVModel(props, 'modelValue', emits)
const _vModel = useVModel(props, 'modelValue', emits)
const vModel = computed({
get: () => _vModel.value,
set: (value: string) => {
if (value === '') {
_vModel.value = null
} else {
_vModel.value = value
}
},
})
const focus: VNodeRef = (el) => (el as HTMLInputElement)?.focus()
</script>

13
packages/nc-gui/components/cell/Float.vue

@ -16,7 +16,18 @@ const emits = defineEmits<Emits>()
const editEnabled = inject(EditModeInj)
const vModel = useVModel(props, 'modelValue', emits)
const _vModel = useVModel(props, 'modelValue', emits)
const vModel = computed({
get: () => _vModel.value,
set: (value: string) => {
if (value === '') {
_vModel.value = null
} else {
_vModel.value = value
}
},
})
const focus: VNodeRef = (el) => (el as HTMLInputElement)?.focus()
</script>

13
packages/nc-gui/components/cell/Integer.vue

@ -16,7 +16,18 @@ const emits = defineEmits<Emits>()
const editEnabled = inject(EditModeInj)
const vModel = useVModel(props, 'modelValue', emits)
const _vModel = useVModel(props, 'modelValue', emits)
const vModel = computed({
get: () => _vModel.value,
set: (value: string) => {
if (value === '') {
_vModel.value = null
} else {
_vModel.value = value
}
},
})
const focus: VNodeRef = (el) => (el as HTMLInputElement)?.focus()

Loading…
Cancel
Save