From aba8b44f918dbd29aaffba180604d6e833bb25d6 Mon Sep 17 00:00:00 2001 From: Sean Perkins Date: Mon, 10 Apr 2023 14:13:26 -0400 Subject: [PATCH] docs(input,searchbar): setFocus usage within overlays (#27142) ## What is the current behavior? The `setFocus` method does not mention extra implementation details required when working within an overlay. Issue URL: N/A ## What is the new behavior? - Adds additional detail about how to use `setFocus()` when inside an overlay - Aligns the `ion-searchbar` documentation to match the `ion-input` documentation ## Does this introduce a breaking change? - [ ] Yes - [x] No ## Other information --- core/src/components.d.ts | 4 ++-- core/src/components/input/input.tsx | 3 +++ core/src/components/searchbar/searchbar.tsx | 8 +++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/core/src/components.d.ts b/core/src/components.d.ts index 59cc60d69b..3b219717f3 100644 --- a/core/src/components.d.ts +++ b/core/src/components.d.ts @@ -1270,7 +1270,7 @@ export namespace Components { */ "required": boolean; /** - * Sets focus on the native `input` in `ion-input`. Use this method instead of the global `input.focus()`. Developers who wish to focus an input when a page enters should call `setFocus()` in the `ionViewDidEnter()` lifecycle method. + * Sets focus on the native `input` in `ion-input`. Use this method instead of the global `input.focus()`. Developers who wish to focus an input when a page enters should call `setFocus()` in the `ionViewDidEnter()` lifecycle method. Developers who wish to focus an input when an overlay is presented should call `setFocus` after `didPresent` has resolved. */ "setFocus": () => Promise; /** @@ -2583,7 +2583,7 @@ export namespace Components { */ "searchIcon"?: string; /** - * Sets focus on the specified `ion-searchbar`. Use this method instead of the global `input.focus()`. + * Sets focus on the native `input` in `ion-searchbar`. Use this method instead of the global `input.focus()`. Developers who wish to focus an input when a page enters should call `setFocus()` in the `ionViewDidEnter()` lifecycle method. Developers who wish to focus an input when an overlay is presented should call `setFocus` after `didPresent` has resolved. */ "setFocus": () => Promise; /** diff --git a/core/src/components/input/input.tsx b/core/src/components/input/input.tsx index 1f99f234c3..c6a97a381d 100644 --- a/core/src/components/input/input.tsx +++ b/core/src/components/input/input.tsx @@ -397,6 +397,9 @@ export class Input implements ComponentInterface { * * Developers who wish to focus an input when a page enters * should call `setFocus()` in the `ionViewDidEnter()` lifecycle method. + * + * Developers who wish to focus an input when an overlay is presented + * should call `setFocus` after `didPresent` has resolved. */ @Method() async setFocus() { diff --git a/core/src/components/searchbar/searchbar.tsx b/core/src/components/searchbar/searchbar.tsx index f4bbcf6b03..85b717169a 100644 --- a/core/src/components/searchbar/searchbar.tsx +++ b/core/src/components/searchbar/searchbar.tsx @@ -243,8 +243,14 @@ export class Searchbar implements ComponentInterface { } /** - * Sets focus on the specified `ion-searchbar`. Use this method instead of the global + * Sets focus on the native `input` in `ion-searchbar`. Use this method instead of the global * `input.focus()`. + * + * Developers who wish to focus an input when a page enters + * should call `setFocus()` in the `ionViewDidEnter()` lifecycle method. + * + * Developers who wish to focus an input when an overlay is presented + * should call `setFocus` after `didPresent` has resolved. */ @Method() async setFocus() {