Skip to content

Commit 668b2da

Browse files
docs(app): add setFocus to the documentation (#29916)
Issue number: resolves #29830 --------- ## What is the current behavior? The `setFocus` method on `ion-app` is marked internal. ## What is the new behavior? Document the `setFocus` method as a way for developers to programmatically focus elements. ## Does this introduce a breaking change? - [ ] Yes - [x] No ## Other information The method isn’t new, it was just marked as internal, which prevented it from being documented. I can mark this as a `feat` though if anyone thinks it should be. Related documentation PR: ionic-team/ionic-docs#3842
1 parent 078ed0b commit 668b2da

File tree

5 files changed

+7
-2
lines changed

5 files changed

+7
-2
lines changed

core/api.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ ion-alert,css-prop,--width,ios
143143
ion-alert,css-prop,--width,md
144144

145145
ion-app,none
146+
ion-app,method,setFocus,setFocus(elements: HTMLElement[]) => Promise<void>
146147

147148
ion-avatar,shadow
148149
ion-avatar,css-prop,--border-radius,ios

core/src/components.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,9 @@ export namespace Components {
304304
"trigger": string | undefined;
305305
}
306306
interface IonApp {
307+
/**
308+
* 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.)
309+
*/
307310
"setFocus": (elements: HTMLElement[]) => Promise<void>;
308311
}
309312
interface IonAvatar {

core/src/components/app/app.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ export class App implements ComponentInterface {
6161
}
6262

6363
/**
64-
* @internal
6564
* Used to set focus on an element that uses `ion-focusable`.
6665
* Do not use this if focusing the element as a result of a keyboard
6766
* event as the focus utility should handle this for us. This method

packages/angular/src/directives/proxies.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ Shorthand for ionAlertDidDismiss.
188188

189189

190190
@ProxyCmp({
191+
methods: ['setFocus']
191192
})
192193
@Component({
193194
selector: 'ion-app',

packages/angular/standalone/src/directives/proxies.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,8 @@ Shorthand for ionAlertDidDismiss.
266266

267267

268268
@ProxyCmp({
269-
defineCustomElementFn: defineIonApp
269+
defineCustomElementFn: defineIonApp,
270+
methods: ['setFocus']
270271
})
271272
@Component({
272273
selector: 'ion-app',

0 commit comments

Comments
 (0)