File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -287,9 +287,30 @@ export class Tabs extends Ion {
287
287
* @private
288
288
*/
289
289
ngAfterContentInit ( ) {
290
+ let preloadTabs = ( isBlank ( this . preloadTabs ) ? this . _config . getBoolean ( 'preloadTabs' ) : isTrueProperty ( this . preloadTabs ) ) ;
291
+
292
+ // get the selected index
290
293
let selectedIndex = this . selectedIndex ? parseInt ( this . selectedIndex , 10 ) : 0 ;
291
294
292
- let preloadTabs = ( isBlank ( this . preloadTabs ) ? this . _config . getBoolean ( 'preloadTabs' ) : isTrueProperty ( this . preloadTabs ) ) ;
295
+ // ensure the selectedIndex isn't a hidden or disabled tab
296
+ // also find the first available index incase we need it later
297
+ let availableIndex = - 1 ;
298
+ this . _tabs . forEach ( ( tab , index ) => {
299
+ if ( tab . enabled && tab . show && availableIndex < 0 ) {
300
+ // we know this tab index is safe to show
301
+ availableIndex = index ;
302
+ }
303
+
304
+ if ( index === selectedIndex && ( ! tab . enabled || ! tab . show ) ) {
305
+ // the selectedIndex is not safe to show
306
+ selectedIndex = - 1 ;
307
+ }
308
+ } ) ;
309
+ if ( selectedIndex < 0 ) {
310
+ // the selected index wasn't safe to show
311
+ // instead use an available index found to be safe to show
312
+ selectedIndex = availableIndex ;
313
+ }
293
314
294
315
this . _tabs . forEach ( ( tab , index ) => {
295
316
if ( index === selectedIndex ) {
You can’t perform that action at this time.
0 commit comments