Skip to content

Commit be9083e

Browse files
authored
Merge pull request #19 from shubhanus/fix/otp-type-alpha-numaric-wrong-keyboard/issue-9
Fixed: Wrong keyboards on mobile devices
2 parents 45aeca0 + f9d05b7 commit be9083e

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/lib/components/Input.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const Input = ({
3030
index,
3131
secure,
3232
inputStyles,
33+
otpType,
3334
...rest
3435
}) => {
3536
const input = useRef(null);
@@ -52,11 +53,16 @@ const Input = ({
5253
}, [focus]);
5354

5455
const handelInputFocus = event => onInputFocus(index, event);
55-
56+
let inputType = "text";
57+
if (secure) {
58+
inputType = "password";
59+
} else if (otpType === "number") {
60+
inputType = "tel";
61+
}
5662
return (
5763
<input
5864
style={{ ...inputDefaultStyles, ...inputStyles }}
59-
type={secure ? "password" : "tel"}
65+
type={inputType}
6066
maxLength="1"
6167
ref={input}
6268
disabled={disabled}
@@ -76,7 +82,8 @@ Input.propTypes = {
7682
disabled: PropTypes.bool,
7783
value: PropTypes.string,
7884
secure: PropTypes.bool,
79-
inputStyles: PropTypes.object
85+
inputStyles: PropTypes.object,
86+
otpType: PropTypes.oneOf(["number", "alpha", "alphanumeric", "any"])
8087
};
8188

8289
export default React.memo(Input);

src/lib/components/OTPReader.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ const OtpInput = ({
5858
autoFocus={autoFocus}
5959
secure={secure}
6060
data-testid="input"
61+
otpType={otpType}
6162
/>
6263
);
6364
}

0 commit comments

Comments
 (0)