Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #13768 Add support of focusOnShow for DynamicDialog #13760

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/app/components/dynamicdialog/dynamicdialog-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ export class DynamicDialogConfig<T = any> {
* @group Props
*/
minY?: number;
/**
* When enabled, first button receives focus on show.
* @group Props
*/
focusOnShow?: boolean;
/**
* Whether the dialog can be displayed full screen.
* @group Props
Expand Down
8 changes: 7 additions & 1 deletion src/app/components/dynamicdialog/dynamicdialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ export class DynamicDialogComponent implements AfterViewInit, OnDestroy {
return this.config.minY ? this.config.minY : 0;
}

get focusOnShow(): boolean {
return this.config.focusOnShow ? this.config.focusOnShow : true;
Copy link
Contributor

@SoyDiego SoyDiego Sep 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to suggest the line return this.config.focusOnShow ?? true;
And also you should edit your first post adding Fix #Number-Of-Issue-That-You-Are-Resolving and when PrimeNG Team approve it, will close automatically.

Thanks

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for feedback.
There's no issue created for this change. Is it mandatory to have one before creating a PR ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please, if you can create the issue and link this PR to the issue will be great
Thanks for your contribution

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done !

}

get keepInViewport(): boolean {
return this.config.keepInViewport!;
}
Expand Down Expand Up @@ -253,7 +257,9 @@ export class DynamicDialogComponent implements AfterViewInit, OnDestroy {
if (this.config.modal !== false) {
this.enableModality();
}
this.focus();
if (this.focusOnShow) {
this.focus();
}
break;

case 'void':
Expand Down