-
Notifications
You must be signed in to change notification settings - Fork 498
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: prevent scroll adjusting number inputs (#1280)
* fix: blur number inputs `onWheel` events * fix: remove duplicate attribute * fix: use `inputMode` and `pattern` * fix: use `type` attribute + replace more fields * fix: missing field * fix: remove attribute
- Loading branch information
Showing
7 changed files
with
51 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { TextField } from '@mui/material' | ||
import { forwardRef, useRef } from 'react' | ||
import type { TextFieldProps } from '@mui/material' | ||
import type { ReactElement } from 'react' | ||
|
||
const NumberField = forwardRef<HTMLInputElement, TextFieldProps>(({ inputProps, ...props }, ref): ReactElement => { | ||
const inputRef = useRef<HTMLInputElement>() | ||
|
||
const handleBlur = () => { | ||
inputRef.current?.blur() | ||
} | ||
|
||
return ( | ||
<TextField | ||
type="number" | ||
autoComplete="off" | ||
inputRef={inputRef} | ||
onWheel={handleBlur} | ||
ref={ref} | ||
inputProps={{ | ||
step: 'any', | ||
...inputProps, | ||
}} | ||
{...props} | ||
/> | ||
) | ||
}) | ||
|
||
NumberField.displayName = 'NumberField' | ||
|
||
export default NumberField |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters