Skip to content

Commit

Permalink
Fixed #14745 - Calendar | Autofocus not working
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmetcetin01140 committed Feb 15, 2024
1 parent 4157578 commit 207830b
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/app/components/autofocus/autofocus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,18 @@ export class AutoFocus {
ngAfterContentChecked() {
if (!this.focused) {
if (this.autofocus) {
const focusableElements = DomHandler.getFocusableElements(this.host.nativeElement);
setTimeout(() => {
const focusableElements = DomHandler.getFocusableElements(this.host.nativeElement);

if (focusableElements.length === 0) {
this.host.nativeElement.focus();
}
if (focusableElements.length > 0) {
focusableElements[0].focus();
}
if (focusableElements.length === 0) {
this.host.nativeElement.focus();
}
if (focusableElements.length > 0) {
focusableElements[0].focus();
}

this.focused = true;
this.focused = true;
});
}
}
}
Expand Down

0 comments on commit 207830b

Please sign in to comment.