primeng
primeng copied to clipboard
Component: Dynamic Dialog's Autofocus on Close Button
Describe the bug
In previous versions, the dynamic dialog did not affect the initial autofocus. However, it focus to the Close button automatically
Environment
No specific environment.
Reproducer
No response
Angular version
16.0.3
PrimeNG version
v16.0.0-rc.2
Build / Runtime
Angular CLI App
Language
TypeScript
Node version (for AoT issues node --version)
v18.16.0
Browser(s)
No response
Steps to reproduce the behavior
- Open a dialog with
closable: truelike this:
this.dialogService.open(ExampleDialogComponent, {
header: 'Dialog header',
closable: false
});
- View the result
Expected behavior
Should be 1 of these solutions:
- Do not allow to autofocus the close button.
- Add new property named
isCloseButtonAutofocusor something like that to make sure that we can turn on/off the autofoccus for the close button.
Yeah same here, latest primeng 16.3.1, we needed to autofocus an input, however only when added closable: false we managed to do so
ive encountered this problem as well and was able to go around it by using the AutoFocusModule in the custom header for my dynamic dialog.
<div class="flex flex-wrap h-full justify-content-between align-items-center" [autofocus]="true">
<div class="flex align-items-center">
....
</div>
<p-button icon="fa-solid fa-xmark" [rounded]="true" [text]="true" [severity]="'secondary'"
(onClick)="closeDialog()"></p-button>
</div>
this.dialogService.open(ReviewCommentsComponent,
{
...
templates: {
header: ReviewCommentHeaderComponent,
},
...
},
);