File tree Expand file tree Collapse file tree 1 file changed +5
-8
lines changed
core/src/components/input-otp Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -686,19 +686,16 @@ export class InputOTP implements ComponentInterface {
686686 }
687687
688688 /**
689- * Loops through the input values and returns the index
689+ * Searches through the input values and returns the index
690690 * of the first empty input.
691691 * Returns -1 if all inputs are filled.
692692 */
693693 private getFirstEmptyIndex ( ) {
694694 const { inputValues, length } = this ;
695-
696- for ( let i = 0 ; i < length ; i ++ ) {
697- if ( ! inputValues [ i ] || inputValues [ i ] === '' ) {
698- return i ;
699- }
700- }
701- return - 1 ;
695+ // Create an array of the same length as the input OTP
696+ // and fill it with the input values
697+ const values = Array . from ( { length } , ( _ , i ) => inputValues [ i ] || '' ) ;
698+ return values . findIndex ( value => ! value || value === '' ) ?? - 1 ;
702699 }
703700
704701 /**
You can’t perform that action at this time.
0 commit comments