Skip to content

Commit

Permalink
Fix number input accepting characters in Firefox (#396)
Browse files Browse the repository at this point in the history
* 🐛 Avoid inputting fields other than number for number inputs

* 📝 Add override prop warning in readme

* 🔖 v3.0.2
  • Loading branch information
prateek3255 authored Apr 29, 2023
1 parent da5167c commit facf432
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,17 @@ export default function App() {
</tr>
</table>

### ⚠️ Warning
Do not override the following props on the input component that you return from the `renderInput` prop. Doing so might lead to unexpected behaviour.
- `ref`
- `value`
- `onChange`
- `onFocus`
- `onBlur`
- `onKeyDown`
- `onPaste`
- `type`

## Migrating from v2

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:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-otp-input",
"version": "3.0.1",
"version": "3.0.2",
"description": "A fully customizable, one-time password input component for the web built with React",
"main": "lib/index.js",
"module": "lib/index.esm.js",
Expand Down
2 changes: 2 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ const OTPInput = ({
event.code === 'ArrowDown'
) {
event.preventDefault();
} else if (isInputNum && !isInputValueValid(event.key)) {
event.preventDefault();
}
};

Expand Down

0 comments on commit facf432

Please sign in to comment.