Skip to content

Commit 5b3d573

Browse files
committed
Fixed #26 - initialFocusField not working for 0 as index
1 parent 120b0b7 commit 5b3d573

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

angular-code-input/src/lib/code-input.component.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,10 @@ export class CodeInputComponent implements AfterViewInit, OnInit, OnChanges, Aft
282282
return;
283283
}
284284

285-
if (!this.initialFocusField) {
286-
return;
287-
}
288-
289-
this.inputs[this.initialFocusField].focus();
290-
this.state.isFocusingAfterAppearingCompleted = document.activeElement === this.inputs[this.initialFocusField];
285+
// tslint:disable-next-line:no-non-null-assertion
286+
this.inputs[this.initialFocusField!].focus();
287+
// tslint:disable-next-line:no-non-null-assertion
288+
this.state.isFocusingAfterAppearingCompleted = document.activeElement === this.inputs[this.initialFocusField!];
291289
}
292290

293291
private emitChanges(): void {

0 commit comments

Comments
 (0)