From 28461f58c0fa83c48d952fa50f22ae24a7e93d45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehmet=20=C3=87etin?= <92744169+mehmetcetin01140@users.noreply.github.com> Date: Fri, 19 Jul 2024 16:33:16 +0300 Subject: [PATCH 1/2] Fixed #16064 - Button | Add focus() method --- src/app/components/button/button.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/app/components/button/button.ts b/src/app/components/button/button.ts index d725a278b6b..18e7e9254b2 100755 --- a/src/app/components/button/button.ts +++ b/src/app/components/button/button.ts @@ -565,6 +565,10 @@ export class Button implements AfterContentInit { 'p-badge-no-gutter': this.badge && String(this.badge).length === 1 }; } + + focus() { + this.el.nativeElement.firstChild.focus(); + } } @NgModule({ From 5a09d5be0c963bf9a0c3eb61f81f9bb47aa29c82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehmet=20=C3=87etin?= <92744169+mehmetcetin01140@users.noreply.github.com> Date: Fri, 19 Jul 2024 16:55:35 +0300 Subject: [PATCH 2/2] refactor --- src/app/components/button/button.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/app/components/button/button.ts b/src/app/components/button/button.ts index 18e7e9254b2..1f51f9031ec 100755 --- a/src/app/components/button/button.ts +++ b/src/app/components/button/button.ts @@ -566,7 +566,11 @@ export class Button implements AfterContentInit { }; } - focus() { + /** + * Applies focus. + * @group Method + */ + public focus() { this.el.nativeElement.firstChild.focus(); } }