@@ -622,17 +622,13 @@ export class InputOTP implements ComponentInterface {
622622 . slice ( 0 , length ) ;
623623 for ( let i = 0 ; i < length ; i ++ ) {
624624 this . inputValues [ i ] = validChars [ i ] || '' ;
625- if ( this . inputRefs [ i ] != null ) {
626- this . inputRefs [ i ] ! . value = validChars [ i ] || '' ;
627- }
625+ this . inputRefs [ i ] . value = validChars [ i ] || '' ;
628626 }
629627 this . updateValue ( event ) ;
630628 // Focus the next empty input or the last one
631629 setTimeout ( ( ) => {
632630 const nextIndex = validChars . length < length ? validChars . length : length - 1 ;
633- if ( this . inputRefs [ nextIndex ] != null ) {
634- this . inputRefs [ nextIndex ] ! . focus ( ) ;
635- }
631+ this . inputRefs [ nextIndex ] . focus ( ) ;
636632 } , 20 ) ;
637633 this . previousInputValues = [ ...this . inputValues ] ;
638634 return ;
@@ -643,7 +639,6 @@ export class InputOTP implements ComponentInterface {
643639 // restore the previous value and exit
644640 if ( value . length > 0 && ! validKeyPattern . test ( value [ value . length - 1 ] ) ) {
645641 input . value = this . inputValues [ index ] || '' ;
646- this . previousInputValues [ index ] = this . inputValues [ index ] || '' ;
647642 this . previousInputValues = [ ...this . inputValues ] ;
648643 return ;
649644 }
@@ -657,7 +652,6 @@ export class InputOTP implements ComponentInterface {
657652 if ( isAllSelected || isEmpty ) {
658653 this . inputValues [ index ] = value ;
659654 input . value = value ;
660- this . previousInputValues [ index ] = value ;
661655 this . updateValue ( event ) ;
662656 this . focusNext ( index ) ;
663657 this . previousInputValues = [ ...this . inputValues ] ;
@@ -678,22 +672,16 @@ export class InputOTP implements ComponentInterface {
678672 // Validate the new character before shifting
679673 if ( ! validKeyPattern . test ( newChar ) ) {
680674 input . value = this . inputValues [ index ] || '' ;
681- this . previousInputValues [ index ] = this . inputValues [ index ] || '' ;
682675 this . previousInputValues = [ ...this . inputValues ] ;
683676 return ;
684677 }
685678 // Shift values right from the end to the insertion point
686679 for ( let i = this . inputValues . length - 1 ; i > index ; i -- ) {
687680 this . inputValues [ i ] = this . inputValues [ i - 1 ] ;
688- if ( this . inputRefs [ i ] != null ) {
689- this . inputRefs [ i ] ! . value = this . inputValues [ i ] || '' ;
690- }
681+ this . inputRefs [ i ] . value = this . inputValues [ i ] || '' ;
691682 }
692683 this . inputValues [ index ] = newChar ;
693- if ( this . inputRefs [ index ] != null ) {
694- this . inputRefs [ index ] ! . value = newChar ;
695- }
696- this . previousInputValues [ index ] = newChar ;
684+ this . inputRefs [ index ] . value = newChar ;
697685 this . updateValue ( event ) ;
698686 this . previousInputValues = [ ...this . inputValues ] ;
699687 return ;
@@ -713,14 +701,12 @@ export class InputOTP implements ComponentInterface {
713701 // Check if the new character is valid before updating the value
714702 if ( ! validKeyPattern . test ( newChar ) ) {
715703 input . value = this . inputValues [ index ] || '' ;
716- this . previousInputValues [ index ] = this . inputValues [ index ] || '' ;
717704 this . previousInputValues = [ ...this . inputValues ] ;
718705 return ;
719706 }
720707
721- input . value = newChar ;
722708 this . inputValues [ index ] = newChar ;
723- this . previousInputValues [ index ] = newChar ;
709+ input . value = newChar ;
724710 this . updateValue ( event ) ;
725711 this . previousInputValues = [ ...this . inputValues ] ;
726712 } ;
0 commit comments