Skip to content

Commit

Permalink
update auto fill mobile chrome
Browse files Browse the repository at this point in the history
  • Loading branch information
hunghg255 committed May 22, 2023
1 parent 9c95575 commit e4262e5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "reactjs-otp-input",
"version": "1.0.1",
"version": "1.0.2",
"description": "A fully customizable, one-time password input component for the web built with React",
"main": "lib/index.js",
"scripts": {

This comment has been minimized.

Copy link
@Datta-Telukunta

Datta-Telukunta Sep 26, 2023

@hunghg255 , Can you please add the peer dependency for React 17 as well?

Expand Down
12 changes: 9 additions & 3 deletions src/lib/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class SingleOtpInput extends PureComponent {
hasErrored && errorStyle
)}
type={this.getType()}
maxLength="1"
// maxLength='1'
ref={this.input}
disabled={isDisabled}
value={value ? value : ''}
Expand Down Expand Up @@ -220,9 +220,15 @@ class OtpInput extends Component {
});
};

handleOnChange = (e) => {
handleOnChange = (idx) => (e) => {
const { value } = e.target;

// Fix Fill value
if (idx === 0 && value.length === this.props.numInputs) {
this.handleOtpChange(value.split(''));
return;
}

if (this.isInputValueValid(value)) {
this.changeCodeAtFocus(value);
}
Expand Down Expand Up @@ -298,7 +304,7 @@ class OtpInput extends Component {
index={i}
focus={activeInput === i}
value={otp && otp[i]}
onChange={this.handleOnChange}
onChange={this.handleOnChange(i)}
onKeyDown={this.handleOnKeyDown}
onInput={this.handleOnInput}
onPaste={this.handleOnPaste}
Expand Down

0 comments on commit e4262e5

Please sign in to comment.