From f8af9dfae49a3148b38b47ccceed181365e4df1f Mon Sep 17 00:00:00 2001 From: Vladyslav Zuiev Date: Fri, 5 Apr 2024 11:59:58 +0200 Subject: [PATCH] Change Number input type to text instead of number 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/ --- .gitignore | 1 + packages/ra-ui-materialui/src/input/NumberInput.tsx | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 30396811043..2adc54e5c3c 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ cypress/screenshots !.yarn/releases !.yarn/sdks !.yarn/versions +.history \ No newline at end of file diff --git a/packages/ra-ui-materialui/src/input/NumberInput.tsx b/packages/ra-ui-materialui/src/input/NumberInput.tsx index e149714b989..d01acade2b2 100644 --- a/packages/ra-ui-materialui/src/input/NumberInput.tsx +++ b/packages/ra-ui-materialui/src/input/NumberInput.tsx @@ -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}