Skip to content

Commit

Permalink
feat(primeng/p-dynamicDialog): add new property to dynamic dialog con…
Browse files Browse the repository at this point in the history
…figs for autoFocus

Fixes primefaces#12643.
  • Loading branch information
volvachev authored and Egor Volvachev committed Feb 19, 2023
1 parent 085a4e6 commit a087f3b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/app/components/dynamicdialog/dynamicdialog-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ export class DynamicDialogConfig<T = any> {
maximizeIcon?: string;
minimizeIcon?: string;
position?: string;
autoFocus?: boolean;
}
4 changes: 4 additions & 0 deletions src/app/components/dynamicdialog/dynamicdialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,10 @@ export class DynamicDialogComponent implements AfterViewInit, OnDestroy {
}

focus() {
if (this.config?.autoFocus === false) {
return;
}

const focusable = DomHandler.getFocusableElements(this.container);
if (focusable && focusable.length > 0) {
this.zone.runOutsideAngular(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,12 @@ <h5>Properties for DynamicDialog</h5>
<td>true</td>
<td>Enables dragging to change the position using header.</td>
</tr>
<tr>
<td>autoFocus</td>
<td>boolean</td>
<td>true</td>
<td>Whether to automatically focus.</td>
</tr>
</tbody>
</table>
</div>
Expand Down

0 comments on commit a087f3b

Please sign in to comment.