11import { readTask , writeTask } from '@stencil/core' ;
22import { clamp } from '@utils/helpers' ;
3+ import { getIonMode } from '../../global/ionic-global' ;
34
45const TRANSITION = 'all 0.2s ease-in-out' ;
56const 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