Browse Source

fix(gui): handle empty string in percent and currency cell as null

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/4762/head
Pranav C 2 years ago
parent
commit
c3503bc82b
  1. 13
      packages/nc-gui/components/cell/Currency.vue
  2. 13
      packages/nc-gui/components/cell/Percent.vue
  3. 2
      packages/nc-gui/composables/useMultiSelect/index.ts

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

@ -14,7 +14,18 @@ const column = inject(ColumnInj)!
const editEnabled = inject(EditModeInj)!
const vModel = useVModel(props, 'modelValue', emit)
const _vModel = useVModel(props, 'modelValue', emit)
const vModel = computed({
get: () => _vModel.value,
set: (value: unknown) => {
if (value === '') {
_vModel.value = null
} else {
_vModel.value = value as number
}
},
})
const lastSaved = ref()

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

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

2
packages/nc-gui/composables/useMultiSelect/index.ts

@ -268,7 +268,7 @@ export function useMultiSelect(
case 67:
// set clipboard context only if single cell selected
// or if selected range is empty
if ((selectedRange.isSingleCell() || selectedRange.isEmpty()) && rowObj.row[columnObj.title!]) {
if (selectedRange.isSingleCell() || (selectedRange.isEmpty() && rowObj && columnObj)) {
clipboardContext = {
value: rowObj.row[columnObj.title!],
uidt: columnObj.uidt as UITypes,

Loading…
Cancel
Save