From 40e7c2e5576118504a5dd4ad53bb11eb879b8d7f Mon Sep 17 00:00:00 2001 From: Brandy Carney Date: Mon, 30 Sep 2024 13:22:10 -0400 Subject: [PATCH] docs(app): add setFocus to the public API --- core/api.txt | 1 + core/src/components.d.ts | 3 +++ core/src/components/app/app.tsx | 1 - packages/angular/src/directives/proxies.ts | 1 + packages/angular/standalone/src/directives/proxies.ts | 3 ++- 5 files changed, 7 insertions(+), 2 deletions(-) diff --git a/core/api.txt b/core/api.txt index 9c620e0c085..bd0490e45fc 100644 --- a/core/api.txt +++ b/core/api.txt @@ -143,6 +143,7 @@ ion-alert,css-prop,--width,ios ion-alert,css-prop,--width,md ion-app,none +ion-app,method,setFocus,setFocus(elements: HTMLElement[]) => Promise ion-avatar,shadow ion-avatar,css-prop,--border-radius,ios diff --git a/core/src/components.d.ts b/core/src/components.d.ts index 7c725cf2c89..db9530b3404 100644 --- a/core/src/components.d.ts +++ b/core/src/components.d.ts @@ -304,6 +304,9 @@ export namespace Components { "trigger": string | undefined; } interface IonApp { + /** + * Used to set focus on an element that uses `ion-focusable`. Do not use this if focusing the element as a result of a keyboard event as the focus utility should handle this for us. This method should be used when we want to programmatically focus an element as a result of another user action. (Ex: We focus the first element inside of a popover when the user presents it, but the popover is not always presented as a result of keyboard action.) + */ "setFocus": (elements: HTMLElement[]) => Promise; } interface IonAvatar { diff --git a/core/src/components/app/app.tsx b/core/src/components/app/app.tsx index d38b0bd37a3..fadfed3f04b 100644 --- a/core/src/components/app/app.tsx +++ b/core/src/components/app/app.tsx @@ -61,7 +61,6 @@ export class App implements ComponentInterface { } /** - * @internal * Used to set focus on an element that uses `ion-focusable`. * Do not use this if focusing the element as a result of a keyboard * event as the focus utility should handle this for us. This method diff --git a/packages/angular/src/directives/proxies.ts b/packages/angular/src/directives/proxies.ts index f448236a161..0f10c6bb5b5 100644 --- a/packages/angular/src/directives/proxies.ts +++ b/packages/angular/src/directives/proxies.ts @@ -188,6 +188,7 @@ Shorthand for ionAlertDidDismiss. @ProxyCmp({ + methods: ['setFocus'] }) @Component({ selector: 'ion-app', diff --git a/packages/angular/standalone/src/directives/proxies.ts b/packages/angular/standalone/src/directives/proxies.ts index c84717dfd1c..bc90bec4d03 100644 --- a/packages/angular/standalone/src/directives/proxies.ts +++ b/packages/angular/standalone/src/directives/proxies.ts @@ -266,7 +266,8 @@ Shorthand for ionAlertDidDismiss. @ProxyCmp({ - defineCustomElementFn: defineIonApp + defineCustomElementFn: defineIonApp, + methods: ['setFocus'] }) @Component({ selector: 'ion-app',