Skip to content

Commit

Permalink
fix: also format inputProps['onChange'] (#2293)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamacook authored Jul 14, 2023
1 parent b0ebdaf commit 01135da
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/components/common/NumberField/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ const NumberField = forwardRef<HTMLInputElement, TextFieldProps>(({ onChange, ..
return onChange?.(event)
}}
{...props}
inputProps={{
...props.inputProps,
// Autocomplete passes `onChange` in `inputProps`
onChange: (event) => {
// inputProps['onChange'] is generically typed
if ('value' in event.target && typeof event.target.value === 'string') {
event.target.value = _formatNumber(event.target.value)
return props.inputProps?.onChange?.(event)
}
},
}}
/>
)
})
Expand Down

0 comments on commit 01135da

Please sign in to comment.