π₯ π₯ π₯ A Free & Self-hostable Airtable Alternative
TypeScript airtableairtable-alternativeautomatic-apihacktoberfestlow-codeno-codeno-code-databaseno-code-platformpostgresqlrest-apirestful-apispreadsheetsqliteswagger
fix: decimal cell show actual db stored value on focus input instead of precision formatted value
Ramesh Manef94a3ad13db9
diff --git a/packages/nc-gui/components/cell/Decimal/DecimalInput.vue b/packages/nc-gui/components/cell/Decimal/DecimalInput.vueindex 7613f094d4..9c44599c0c 100644--- a/packages/nc-gui/components/cell/Decimal/DecimalInput.vue+++ b/packages/nc-gui/components/cell/Decimal/DecimalInput.vue@@ -45,10 +45,10 @@ const pasteText = (target: HTMLInputElement, value: string) => {}}-const getFormattedModelValue = () => {+const getFormattedModelValue = (format = true) => {if (vModel.value || vModel.value === 0) {if (typeof vModel.value === 'number') {- if (props.precision) {+ if (props.precision && format) {return vModel.value.toFixed(props.precision) ?? ''} else {return vModel.value.toString()@@ -56,7 +56,7 @@ const getFormattedModelValue = () => {} else if (typeof vModel.value === 'string') {const numberValue = Number(vModel.value)if (!ncIsNaN(numberValue)) {- if (props.precision) {+ if (props.precision && format) {return numberValue.toFixed(props.precision) ?? ''} else {return numberValue.toString()@@ -67,9 +67,9 @@ const getFormattedModelValue = () => {return ''}-const refreshVModel = () => {+const refreshVModel = (format = true) => {if (inputRef.value && (vModel.value || vModel.value === 0)) {- inputRef.value.value = getFormattedModelValue()+ inputRef.value.value = getFormattedModelValue(format)}}const saveValue = (targetValue: string) => {@@ -181,11 +181,24 @@ const onInputBlur = (e: FocusEvent) => {}}+const onInputFocus = () => {+ refreshVModel(false)+}+const registerEvents = (input: HTMLInputElement) => {input.addEventListener('keydown', onInputKeyDown)input.addEventListener('keyup', onInputKeyUp)input.addEventListener('paste', onInputPaste)input.addEventListener('blur', onInputBlur)+ input.addEventListener('focus', onInputFocus)+}++const removeEvents = (input: HTMLInputElement) => {+ input.removeEventListener('keydown', onInputKeyDown)+ input.removeEventListener('keyup', onInputKeyUp)+ input.removeEventListener('paste', onInputPaste)+ input.removeEventListener('blur', onInputBlur)+ input.removeEventListener('focus', onInputFocus)}const onBeforeInput = (e: InputEvent) => {@@ -209,6 +222,12 @@ onMounted(() => {}})+onBeforeUnmount(() => {+ if (inputRef.value) {+ removeEvents(inputRef.value as HTMLInputElement)+ }+})+watch(vModel, (newValue) => {if (!inputRef.value ||