Skip to content

Commit

Permalink
Merge pull request #14814 from primefaces/issue-14745
Browse files Browse the repository at this point in the history
Fixed #14745 - Calendar | Autofocus not working
  • Loading branch information
cetincakiroglu authored Feb 22, 2024
2 parents bf1d200 + 207830b commit 2f125ac
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 2f125ac

Please sign in to comment.