@@ -55,9 +55,7 @@ export class CoreTabComponent implements OnInit, OnDestroy {
5555
5656 if ( this . initialized && hasChanged ) {
5757 this . tabs . tabVisibilityChanged ( ) ;
58-
59- this . tabElement = document . getElementById ( this . id + '-tab' ) ;
60- this . tabElement && this . tabElement . setAttribute ( 'aria-hidden' , ! this . _show ) ;
58+ this . updateAriaHidden ( ) ;
6159 }
6260 }
6361 }
@@ -96,8 +94,7 @@ export class CoreTabComponent implements OnInit, OnDestroy {
9694 this . initialized = true ;
9795
9896 setTimeout ( ( ) => {
99- this . tabElement = document . getElementById ( this . id + '-tab' ) ;
100- this . tabElement && this . tabElement . setAttribute ( 'aria-hidden' , ! this . _show ) ;
97+ this . updateAriaHidden ( ) ;
10198 } , 1000 ) ;
10299 }
103100
@@ -116,8 +113,8 @@ export class CoreTabComponent implements OnInit, OnDestroy {
116113
117114 this . tabElement = this . tabElement || document . getElementById ( this . id + '-tab' ) ;
118115
116+ this . updateAriaHidden ( ) ;
119117 this . tabElement && this . tabElement . setAttribute ( 'aria-selected' , true ) ;
120- this . tabElement && this . tabElement . setAttribute ( 'aria-hidden' , ! this . _show ) ;
121118
122119 this . loaded = true ;
123120 this . ionSelect . emit ( this ) ;
@@ -137,8 +134,8 @@ export class CoreTabComponent implements OnInit, OnDestroy {
137134 * Unselect tab.
138135 */
139136 unselectTab ( ) : void {
137+ this . updateAriaHidden ( ) ;
140138 this . tabElement && this . tabElement . setAttribute ( 'aria-selected' , false ) ;
141- this . tabElement && this . tabElement . setAttribute ( 'aria-hidden' , true ) ;
142139
143140 this . element . classList . remove ( 'selected' ) ;
144141 this . showHideNavBarButtons ( false ) ;
@@ -176,4 +173,17 @@ export class CoreTabComponent implements OnInit, OnDestroy {
176173 instances [ i ] . forceHide ( ! show ) ;
177174 }
178175 }
176+
177+ /**
178+ * Update aria hidden attribute.
179+ */
180+ updateAriaHidden ( ) : void {
181+ if ( ! this . tabElement ) {
182+ this . tabElement = document . getElementById ( this . id + '-tab' ) ;
183+ }
184+
185+ if ( this . tabElement ) {
186+ this . tabElement && this . tabElement . setAttribute ( 'aria-hidden' , ! this . _show ) ;
187+ }
188+ }
179189}
0 commit comments