Skip to content

Commit facf432

Browse files
authored
Fix number input accepting characters in Firefox (#396)
* 🐛 Avoid inputting fields other than number for number inputs * 📝 Add override prop warning in readme * 🔖 v3.0.2
1 parent da5167c commit facf432

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,17 @@ export default function App() {
131131
</tr>
132132
</table>
133133

134+
### ⚠️ Warning
135+
Do not override the following props on the input component that you return from the `renderInput` prop. Doing so might lead to unexpected behaviour.
136+
- `ref`
137+
- `value`
138+
- `onChange`
139+
- `onFocus`
140+
- `onBlur`
141+
- `onKeyDown`
142+
- `onPaste`
143+
- `type`
144+
134145
## Migrating from v2
135146

136147
The v3 of `react-otp-input` is a complete rewrite of the library. Apart from making the API more customizable and flexible, this version is a complete rewrite of the library using TypeScript and React Hooks. Here are the breaking changes that you need to be aware of:

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-otp-input",
3-
"version": "3.0.1",
3+
"version": "3.0.2",
44
"description": "A fully customizable, one-time password input component for the web built with React",
55
"main": "lib/index.js",
66
"module": "lib/index.esm.js",

src/index.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ const OTPInput = ({
151151
event.code === 'ArrowDown'
152152
) {
153153
event.preventDefault();
154+
} else if (isInputNum && !isInputValueValid(event.key)) {
155+
event.preventDefault();
154156
}
155157
};
156158

0 commit comments

Comments
 (0)