Skip to content

Commit e4262e5

Browse files
committed
update auto fill mobile chrome
1 parent 9c95575 commit e4262e5

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "reactjs-otp-input",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "A fully customizable, one-time password input component for the web built with React",
55
"main": "lib/index.js",
66
"scripts": {

src/lib/index.jsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class SingleOtpInput extends PureComponent {
101101
hasErrored && errorStyle
102102
)}
103103
type={this.getType()}
104-
maxLength="1"
104+
// maxLength='1'
105105
ref={this.input}
106106
disabled={isDisabled}
107107
value={value ? value : ''}
@@ -220,9 +220,15 @@ class OtpInput extends Component {
220220
});
221221
};
222222

223-
handleOnChange = (e) => {
223+
handleOnChange = (idx) => (e) => {
224224
const { value } = e.target;
225225

226+
// Fix Fill value
227+
if (idx === 0 && value.length === this.props.numInputs) {
228+
this.handleOtpChange(value.split(''));
229+
return;
230+
}
231+
226232
if (this.isInputValueValid(value)) {
227233
this.changeCodeAtFocus(value);
228234
}
@@ -298,7 +304,7 @@ class OtpInput extends Component {
298304
index={i}
299305
focus={activeInput === i}
300306
value={otp && otp[i]}
301-
onChange={this.handleOnChange}
307+
onChange={this.handleOnChange(i)}
302308
onKeyDown={this.handleOnKeyDown}
303309
onInput={this.handleOnInput}
304310
onPaste={this.handleOnPaste}

0 commit comments

Comments
 (0)