diff --git a/src/lib/hooks/useOTP.js b/src/lib/hooks/useOTP.js index 0d4ec13..6c15d1f 100644 --- a/src/lib/hooks/useOTP.js +++ b/src/lib/hooks/useOTP.js @@ -111,7 +111,13 @@ const useOTP = ({ autoFocus, value, otpType, onChange, OTPLength }) => { case "Backspace": e.preventDefault(); changeActiveInputValue(""); - focusInputByDirection("prev"); + /** + * This will make easy to change the current input feild without following a long process of prev input to the next input. + */ + + if (e.target && e.target.value === "" || e.target.value === undefined || e.target.value === null) { + focusInputByDirection("prev"); + } break; case "Delete": e.preventDefault();