Anton Styopin
Anton Styopin

Reputation: 753

PrimeNG Dialog prevent autofocus on first button

I want to prevent the autofocus on the first input element when open the PrimeNG dialog.

<p-dialog header="User Details" [(visible)]="displayDialog" 
   [responsive]="true" showEffect="fade"
   [modal]="true" (onAfterHide)="onDialogHide()">
   <p-button icon="fa fa-fw fa-minus"
              label="Delete" class="delete-button">
    </p-button>
</p-dialog>

Is there a possibility to prevent the autofocus?

Upvotes: 4

Views: 3992

Answers (2)

VoloCorp
VoloCorp

Reputation: 21

focusOnShow can be used only if you have p-dialog. If you are using dialog service then there is no possibility to remove autoFocus, or I just couldn't find.

Upvotes: 1

Jim Barrett
Jim Barrett

Reputation: 467

Not sure if you're still looking for an answer but there is a focusOnShow attribute for p-dialog which defaults to true. Set it to false will stop focusing on the first button. Not sure which version of PrimeNG this was introduced in.

Upvotes: 12

Related Questions