From ec32237c105b531dc1966380dd817f9f9e358500 Mon Sep 17 00:00:00 2001 From: VimLeSai Date: Mon, 5 Oct 2020 12:36:45 +0530 Subject: [PATCH] This will make easy to change the current input feild without following a long process of prev input to the next input. --- src/lib/hooks/useOTP.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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();