Skip to content

Commit 278c42a

Browse files
committed
chore: update content
1 parent abf178b commit 278c42a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

docs/developing/autofocus.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ title: Autofocus
1010
/>
1111
</head>
1212

13-
Developers that want to set focus to an element on "page load" can use the `setFocus` API to set focus to an element. This API should be used in place of the `autofocus` attribute and called within the `ionViewDidEnter` lifecycle event for routing applications and the `appload` event for vanilla JavaScript applications.
13+
The `autofocus` attribute is a standard HTML attribute that allows developers to set focus to an element when a page loads. This attribute is commonly used to set focus to the first input element on a page. However, the `autofocus` attribute can cause issues in routing applications when navigating between pages. This is because the `autofocus` attribute will set focus to the element when the page loads, but will not set focus to the element when the page is revisited.
14+
15+
# Managing Focus
16+
17+
Ionic provides a `setFocus` API that allows developers to manually set focus to an element. This API should be used in place of the `autofocus` attribute and called within the `ionViewDidEnter` lifecycle event for routing applications, within the `didPresent` lifecycle event for overlays, and the `appload` event for vanilla JavaScript applications.
1418

1519
The example below highlights the difference in behavior between the `autofocus` attribute and the `setFocus` API.
1620

0 commit comments

Comments
 (0)