primeng icon indicating copy to clipboard operation
primeng copied to clipboard

Component: Dynamic Dialog's Autofocus on Close Button

Open tranvanthinh300993 opened this issue 3 years ago • 2 comments

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

  1. Open a dialog with closable: true like this:
this.dialogService.open(ExampleDialogComponent, {
    header: 'Dialog header',
    closable: false
});
  1. View the result

Screenshot from 2023-06-08 09-03-39

Expected behavior

Should be 1 of these solutions:

  • Do not allow to autofocus the close button.
  • Add new property named isCloseButtonAutofocus or something like that to make sure that we can turn on/off the autofoccus for the close button.

tranvanthinh300993 avatar Jun 08 '23 02:06 tranvanthinh300993

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

tomer953 avatar Sep 18 '23 17:09 tomer953

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,
        },
...
      },
      );
      

bvx5009 avatar Jan 30 '24 15:01 bvx5009