@@ -431,7 +431,7 @@ export class Picker implements ComponentInterface {
431431 /**
432432 * Attempts to intelligently search the first and second
433433 * column as if they're number columns for the provided numbers
434- * where the first two numbers inpu are the first column
434+ * where the first two numbers are the first column
435435 * and the last 2 are the last column. Tries to allow for the first
436436 * number to be ignored for situations where typos occurred.
437437 */
@@ -446,20 +446,31 @@ export class Picker implements ComponentInterface {
446446
447447 const inputArray = input . split ( '' ) ;
448448 const hourValue = inputArray . slice ( 0 , 2 ) . join ( '' ) ;
449+ // Try to find a match for the first two digits in the first column
449450 const foundHour = this . searchColumn ( firstColumn , hourValue ) ;
450451
452+ // If we have more than 2 digits and found a match for hours,
453+ // use the remaining digits for the second column (minutes)
451454 if ( inputArray . length > 2 && foundHour ) {
452455 const minuteValue = inputArray . slice ( 2 , 4 ) . join ( '' ) ;
453456 this . searchColumn ( secondColumn , minuteValue ) ;
454- } else if ( ! foundHour && inputArray . length >= 1 ) {
457+ }
458+ // If we couldn't find a match for the two-digit hour, try single digit approaches
459+ else if ( ! foundHour && inputArray . length >= 1 ) {
460+ // First try the first digit as a single-digit hour
455461 let singleDigitHour = inputArray [ 0 ] ;
456462 let singleDigitFound = this . searchColumn ( firstColumn , singleDigitHour ) ;
463+
464+ // If that didn't work, try the second digit as a single-digit hour
465+ // (handles case where user made a typo in the first digit, or they typed over themselves)
457466 if ( ! singleDigitFound ) {
458467 inputArray . shift ( ) ;
459468 singleDigitHour = inputArray [ 0 ] ;
460469 singleDigitFound = this . searchColumn ( firstColumn , singleDigitHour ) ;
461470 }
462471
472+ // If we found a single-digit hour and have remaining digits,
473+ // use up to 2 of the remaining digits for the second column
463474 if ( singleDigitFound && inputArray . length > 1 ) {
464475 const remainingDigits = inputArray . slice ( 1 , 3 ) . join ( '' ) ;
465476 this . searchColumn ( secondColumn , remainingDigits ) ;
0 commit comments