Skip to content

Commit

Permalink
Fix bug with numeric input
Browse files Browse the repository at this point in the history
  • Loading branch information
paulpopus committed Feb 10, 2024
1 parent a34ac12 commit c9bfcb3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/fields/Number/NumericComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@ const NumericComponent: React.FC<Props> = ({
const afterInput = admin?.components?.afterInput
const { callback, ...componentProps } = config

console.log('componentProps', componentProps)

const formatValue = useCallback(
(value: string) => {
const prefix = componentProps.prefix
const suffix = componentProps.suffix
const thousandSeparator = componentProps.thousandSeparator

if (callback) {
return callback(value)
Expand All @@ -51,7 +54,12 @@ const NumericComponent: React.FC<Props> = ({

if (suffix) cleanValue = cleanValue.replaceAll(suffix, '')

cleanValue = parseFloat(cleanValue)
if (thousandSeparator) {
cleanValue =
typeof thousandSeparator === 'string'
? cleanValue.replaceAll(thousandSeparator, '')
: cleanValue.replaceAll(',', '')
}

return cleanValue
} else {
Expand Down

0 comments on commit c9bfcb3

Please sign in to comment.