Skip to content

Commit

Permalink
Change Number input type to text instead of number
Browse files Browse the repository at this point in the history
There are multiple problems when it comes to number input e.g. there is empty input ref value when inputted value is not a number. So, in the context you will have null but on UI you'll still see value with overlaying label.
For more limitations you can read following article.
https://technology.blog.gov.uk/2020/02/24/why-the-gov-uk-design-system-team-changed-the-input-type-for-numbers/
  • Loading branch information
Vladyslav Zuiev committed Apr 5, 2024
1 parent fd2ca41 commit f8af9df
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ cypress/screenshots
!.yarn/releases
!.yarn/sdks
!.yarn/versions
.history
4 changes: 3 additions & 1 deletion packages/ra-ui-materialui/src/input/NumberInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ export const NumberInput = ({
onFocus={handleFocus}
onBlur={handleBlur}
className={clsx('ra-input', `ra-input-${source}`, className)}
type="number"
type="text"
inputmode="numeric"
pattern="[0-9]*"
size="small"
variant={variant}
error={(isTouched || isSubmitted) && invalid}
Expand Down

0 comments on commit f8af9df

Please sign in to comment.