Skip to content

Commit

Permalink
feat: allow comma in number field
Browse files Browse the repository at this point in the history
  • Loading branch information
hashtagnulla committed May 28, 2024
1 parent 54b46a9 commit f5cd536
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/sn-controls-react/src/fieldcontrols/number.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ export const NumberField: React.FC<ReactClientFieldSetting<NumberFieldSetting |
const [value, setValue] = useState(initialState)

const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement | HTMLSelectElement>) => {
setValue(e.target.value)
const inputValue = e.target.value.replace(/[^0-9.,]/g, '')
setValue(inputValue)
props.fieldOnChange?.(props.settings.Name, e.target.value)
}

/**
* Returns steps value by decimal and step settings
*/
Expand Down Expand Up @@ -60,7 +60,7 @@ export const NumberField: React.FC<ReactClientFieldSetting<NumberFieldSetting |
<TextField
autoFocus={props.autoFocus}
name={props.settings.Name}
type="number"
type="text"
label={props.settings.DisplayName}
value={value}
required={props.settings.Compulsory}
Expand Down

0 comments on commit f5cd536

Please sign in to comment.