Skip to content

Commit 07a60ca

Browse files
fix(header): scope banner role toggling to iOS mode only
1 parent 42e044d commit 07a60ca

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

core/src/components/header/header.utils.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { readTask, writeTask } from '@stencil/core';
22
import { clamp } from '@utils/helpers';
3+
import { getIonMode } from '../../global/ionic-global';
34

45
const TRANSITION = 'all 0.2s ease-in-out';
56
const ROLE_NONE = 'none';
@@ -171,9 +172,15 @@ export const setHeaderActive = (headerIndex: HeaderIndex, active = true) => {
171172
const headerEl = headerIndex.el;
172173
const toolbars = headerIndex.toolbars;
173174
const ionTitles = toolbars.map((toolbar) => toolbar.ionTitleEl);
175+
// In iOS, two headers are visible at once (large title + small title).
176+
// Only one can have role="banner" at a time, so we toggle it on scroll.
177+
// In other modes, the role is set once by the render and never needs to change.
178+
const shouldManageRole = getIonMode(headerEl) === 'ios';
174179

175180
if (active) {
176-
headerEl.setAttribute('role', ROLE_BANNER);
181+
if (shouldManageRole) {
182+
headerEl.setAttribute('role', ROLE_BANNER);
183+
}
177184
headerEl.classList.remove('header-collapse-condense-inactive');
178185

179186
ionTitles.forEach((ionTitle) => {
@@ -191,7 +198,9 @@ export const setHeaderActive = (headerIndex: HeaderIndex, active = true) => {
191198
* To solve this, the role needs to be toggled
192199
* based on which header is active.
193200
*/
194-
headerEl.setAttribute('role', ROLE_NONE);
201+
if (shouldManageRole) {
202+
headerEl.setAttribute('role', ROLE_NONE);
203+
}
195204
headerEl.classList.add('header-collapse-condense-inactive');
196205

197206
/**

0 commit comments

Comments
 (0)