This repository was archived by the owner on Mar 9, 2025. It is now read-only.
File tree 3 files changed +14
-6
lines changed
3 files changed +14
-6
lines changed Original file line number Diff line number Diff line change 1
1
import React from "react" ;
2
2
3
3
import { useCompare , useInputSelection } from "src/shared/hooks" ;
4
- import { isValidNumberInput } from "src/shared/validators" ;
4
+ import { isNumber , isValidNumberInput } from "src/shared/validators" ;
5
5
import { MenuCloseRequest } from "src/shared/menu/types" ;
6
6
import { numberInputStyle } from "src/react/table-app/shared-styles" ;
7
7
@@ -18,7 +18,8 @@ export default function CurrencyCellEdit({
18
18
onChange,
19
19
onMenuClose,
20
20
} : Props ) {
21
- const [ localValue , setLocalValue ] = React . useState ( value ) ;
21
+ const initialValue = isNumber ( value ) ? value : "" ;
22
+ const [ localValue , setLocalValue ] = React . useState ( initialValue ) ;
22
23
const inputRef = React . useRef < HTMLInputElement | null > ( null ) ;
23
24
const { setPreviousSelectionStart } = useInputSelection (
24
25
inputRef ,
Original file line number Diff line number Diff line change 1
1
import React from "react" ;
2
2
3
3
import { useCompare , useInputSelection } from "src/shared/hooks" ;
4
- import { isValidNumberInput } from "src/shared/validators" ;
4
+ import { isNumber , isValidNumberInput } from "src/shared/validators" ;
5
5
import { MenuCloseRequest } from "src/shared/menu/types" ;
6
6
import { numberInputStyle } from "src/react/table-app/shared-styles" ;
7
7
@@ -18,7 +18,8 @@ export default function NumberCellEdit({
18
18
onChange,
19
19
onMenuClose,
20
20
} : Props ) {
21
- const [ localValue , setLocalValue ] = React . useState ( value ) ;
21
+ const initialValue = isNumber ( value ) ? value : "" ;
22
+ const [ localValue , setLocalValue ] = React . useState ( initialValue ) ;
22
23
const inputRef = React . useRef < HTMLInputElement | null > ( null ) ;
23
24
const { setPreviousSelectionStart } = useInputSelection (
24
25
inputRef ,
Original file line number Diff line number Diff line change @@ -46,12 +46,17 @@ export const getEmbedContent = (markdown: string) => {
46
46
return markdown ;
47
47
} ;
48
48
49
+ export const getNumberCellContent = ( value : string ) => {
50
+ if ( isNumber ( value ) ) return value ;
51
+ return "" ;
52
+ } ;
53
+
49
54
export const getCurrencyCellContent = (
50
55
value : string ,
51
56
currencyType : CurrencyType
52
57
) => {
53
58
if ( isNumber ( value ) ) return stringToCurrencyString ( value , currencyType ) ;
54
- return value ;
59
+ return "" ;
55
60
} ;
56
61
57
62
export const getCellContent = (
@@ -62,8 +67,9 @@ export const getCellContent = (
62
67
switch ( column . type ) {
63
68
case CellType . TEXT :
64
69
case CellType . FILE :
65
- case CellType . NUMBER :
66
70
return cell . markdown ;
71
+ case CellType . NUMBER :
72
+ return getNumberCellContent ( cell . markdown ) ;
67
73
case CellType . EMBED :
68
74
return getEmbedContent ( cell . markdown ) ;
69
75
case CellType . CHECKBOX :
You can’t perform that action at this time.
0 commit comments