-
Notifications
You must be signed in to change notification settings - Fork 65
Fix issues with tabs that are activated via an ngIf #1887
Conversation
… to better register changes after initial load of tabset
Codecov Report
@@ Coverage Diff @@
## master #1887 +/- ##
======================================
Coverage 100% 100%
======================================
Files 414 414
Lines 8642 8643 +1
Branches 1279 1279
======================================
+ Hits 8642 8643 +1
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #1887 +/- ##
======================================
Coverage 100% 100%
======================================
Files 414 414
Lines 8663 8664 +1
Branches 1282 1282
======================================
+ Hits 8663 8664 +1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for cleaning up those tests. Just one question for you.
src/modules/tabs/tabset.component.ts
Outdated
@@ -95,8 +95,10 @@ export class SkyTabsetComponent | |||
// initialize each tab's index. (in case tabs are instantiated out of order) | |||
this.tabs.forEach(item => item.initializeTabIndex()); | |||
this.tabs.changes.subscribe((change: QueryList<SkyTabComponent>) => { | |||
change.filter(tab => tab.tabIndex === undefined) | |||
.forEach(item => item.initializeTabIndex()); | |||
this.tabsetService.tabs.subscribe(currentTabs => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need a nested subscription here? Could we get what we need by just listening to the service?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we need the first subscription here to know what has changed in the DOM . We then need the second subscription to know what the service currently recognizes. We then filter the DOM tabs to find only the ones that the service doesn't know about and then we initialize those in order to have the service recognize them.
I'm happy you asked the question though as I wasn't having the inner subscription close after the first output so it would have potentially led to memory issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 sounds good. nice catch on the inner sub.
#1883