You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/developing/config.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -202,4 +202,4 @@ Below are the config options that Ionic uses.
202
202
|`toastLeave`|`AnimationBuilder`| Provides a custom leave animation for all `ion-toast`, overriding the default "animation". |
203
203
|`toggleOnOffLabels`|`boolean`| Overrides the default `enableOnOffLabels` in all `ion-toggle` components. |
204
204
|`experimentalCloseWatcher`|`boolean`|**Experimental:** If `true`, the [CloseWatcher API](https://github.com/WICG/close-watcher) will be used to handle all Escape key and hardware back button presses to dismiss menus and overlays and to navigate. Note that the `hardwareBackButton` config option must also be `true`. |
205
-
|`focusManagerPriority`|[`FocusManagerPriority[]`](./managing-focus)|**Experimental:** When defined, Ionic will move focus to the appropriate element after each page transition. This ensures that users relying on assistive technology are informed when a page transition happens. Disabled by default. |
205
+
|`focusManagerPriority`|[`FocusManagerPriority[]`](./managing-focus#types)|**Experimental:** When defined, Ionic will move focus to the appropriate element after each page transition. This ensures that users relying on assistive technology are informed when a page transition happens. Disabled by default. |
Copy file name to clipboardExpand all lines: docs/developing/managing-focus.md
+48-5Lines changed: 48 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,33 +13,35 @@ import TabItem from '@theme/TabItem';
13
13
/>
14
14
</head>
15
15
16
+
## Manual Focus Management
17
+
16
18
Ionic provides a `setFocus` API on components such as [Input](../api/input), [Searchbar](../api/searchbar), and [Textarea](../api/textarea) that allows developers to manually set focus to an element. This API should be used in place of the `autofocus` attribute and called within:
17
19
18
20
- The `ionViewDidEnter` lifecycle event for routing applications when a page is entered.
19
21
- The `didPresent` lifecycle event for overlays when an overlay is presented.
20
22
- The `appload` event for vanilla JavaScript applications when the application loads.
21
23
- The result of a user gesture or interaction.
22
24
23
-
## Why not autofocus?
25
+
###Why not autofocus?
24
26
25
27
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. Learn more about the `autofocus` attribute in the [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autofocus).
26
28
27
-
## Platform Restrictions
29
+
###Platform Restrictions
28
30
29
31
There are platform restrictions you should be aware of when using the `setFocus` API, including:
30
32
31
33
1. Android requires user interaction before setting focus to an element. This can be as simple as a user tapping on the screen.
32
34
2. Interactive elements can only focused a result of a user gesture on Mobile Safari (iOS), such as calling `setFocus` as the result of a button click.
33
35
34
-
## Basic Usage
36
+
###Basic Usage
35
37
36
38
The example below demonstrates how to use the `setFocus` API to request focus on an input when the user clicks a button.
37
39
38
40
import Basic from '@site/static/usage/v8/input/set-focus/index.md';
39
41
40
42
<Basic />
41
43
42
-
## Routing
44
+
###Routing
43
45
44
46
Developers can use the `ionViewDidEnter` lifecycle event to set focus to an element when a page is entered.
45
47
@@ -126,7 +128,7 @@ export default Home;
126
128
</Tabs>
127
129
````
128
130
129
-
## Overlays
131
+
###Overlays
130
132
131
133
Developers can use the `didPresent` lifecycle event to set focus to an element when an overlay is presented.
132
134
@@ -236,3 +238,44 @@ export default Home;
236
238
</TabItem>
237
239
</Tabs>
238
240
````
241
+
242
+
## Assistive Technology Focus Management
243
+
244
+
By default, Single Page Applications have no built-in way of informing screen readers that the active view has changed in a browser or webview. This means that users who rely on assistive technology do not always know if a navigation event occurred.
245
+
246
+
Developers who enable the [focusManagerPriority config](./config#ionicconfig) can delegate focus management to Ionic during page transitions. When enabled, Ionic will move focus to the correct element as specified in the config option. This will inform screen readers that a navigation event occurred.
The following table explains what each content type represents:
257
+
258
+
| Type | Description | Ionic Component | Semantic HTML Equivalent | Landmark Equivalent |
259
+
| - | - | - | - | - |
260
+
|`content`| The main portion of the view. |[Content](../api/content)|[`main`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/main)|[`role="main"`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/Main_role)|
261
+
|`heading`| The title of the view. |[Title](../api/title)|[`h1`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/h1)|[`role="heading"`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/heading_role) with [`aria-level="1"`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-level)|
262
+
|`banner`| The header of the view. |[Header](../api/header)|[`header`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/header)|[`role="banner"`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/Banner_Role)|
263
+
264
+
:::important
265
+
TODO
266
+
:::
267
+
268
+
### Specifying Priority
269
+
270
+
The config should be specified in order is decreasing priority. In the following example, the focus manager will always focus headings. Ionic only proceeds to the next focus priority if a view does not have a previous focus priority. In the following example, Ionic will only focus the banner if a view does not have a heading:
271
+
272
+
```js
273
+
focusManagerPriority: ['heading', 'banner']
274
+
```
275
+
276
+
### Implementation Notes
277
+
278
+
- When specifying a focus priority, browsers may still move focus within that focus priority. For example, when specifying a `'content'` focus priority, Ionic will move focus to the content. However, the browser may then move focus within that content to the first focusable element such as a button.
279
+
- If the focus priority does not match any elements in a view, Ionic will instead focus the view itself to ensure focus generally moves to the correct place. Browsers may then adjust focus within the view.
280
+
- When navigating from the current view to the previous view, Ionic will move focus back to the element that presented the current view.
281
+
- The focus manager can be overridden on a per-view basis as shown in [Manual Focus Management with Routing](#routing).
0 commit comments