diff --git a/core/api.txt b/core/api.txt index 9c620e0c08..bd0490e45f 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 7c725cf2c8..db9530b340 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 d38b0bd37a..fadfed3f04 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 f448236a16..0f10c6bb5b 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 c84717dfd1..bc90bec4d0 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',