From cf760e66f0178425017d820226b2cdcc46202f25 Mon Sep 17 00:00:00 2001 From: shubham-df Date: Tue, 12 Mar 2024 11:47:14 +0530 Subject: [PATCH] Fix input focus issue in react-otp-input Resolved the issue where entering a value in a focused input box would incorrectly fill the previous empty input boxes. Now the value is correctly filled in the currently focused input field. --- src/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.tsx b/src/index.tsx index 3afd218..21fa653 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -70,7 +70,7 @@ const OTPInput = ({ const [activeInput, setActiveInput] = React.useState(0); const inputRefs = React.useRef>([]); - const getOTPValue = () => (value ? value.toString().split('') : []); + const getOTPValue = () => (value ? value.toString().split('') : Array(numInputs).fill(' ')); const isInputNum = inputType === 'number' || inputType === 'tel';