-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(tabs): not picking up indirect descendant tabs in ivy #17346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,5 @@ export { | |
MatTabHeaderPosition, | ||
MatTabsConfig, | ||
MAT_TABS_CONFIG, | ||
MAT_TAB_GROUP, | ||
} from '@angular/material/tabs'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,9 +36,10 @@ import { | |
mixinDisableRipple, | ||
ThemePalette, | ||
} from '@angular/material/core'; | ||
import {merge, Subscription} from 'rxjs'; | ||
import {MatTab} from './tab'; | ||
import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations'; | ||
import {merge, Subscription} from 'rxjs'; | ||
import {startWith} from 'rxjs/operators'; | ||
import {MatTab, MAT_TAB_GROUP} from './tab'; | ||
|
||
|
||
/** Used to generate unique ID's for each tab component */ | ||
|
@@ -88,10 +89,18 @@ interface MatTabGroupBaseHeader { | |
// tslint:disable-next-line:class-name | ||
export abstract class _MatTabGroupBase extends _MatTabGroupMixinBase implements AfterContentInit, | ||
AfterContentChecked, OnDestroy, CanColor, CanDisableRipple { | ||
abstract _tabs: QueryList<MatTab>; | ||
|
||
/** | ||
* All tabs inside the tab group. This includes tabs that belong to groups that are nested | ||
* inside the current one. We filter out only the tabs that belong to this group in `_tabs`. | ||
*/ | ||
abstract _allTabs: QueryList<MatTab>; | ||
crisbeto marked this conversation as resolved.
Show resolved
Hide resolved
|
||
abstract _tabBodyWrapper: ElementRef; | ||
abstract _tabHeader: MatTabGroupBaseHeader; | ||
|
||
/** All of the tabs that belong to the group. */ | ||
_tabs: QueryList<MatTab> = new QueryList<MatTab>(); | ||
|
||
/** The tab index that should be selected after the content has been checked. */ | ||
private _indexToSelect: number | null = 0; | ||
|
||
|
@@ -220,6 +229,7 @@ export abstract class _MatTabGroupBase extends _MatTabGroupMixinBase implements | |
} | ||
|
||
ngAfterContentInit() { | ||
this._subscribeToAllTabChanges(); | ||
this._subscribeToTabLabels(); | ||
|
||
// Subscribe to changes in the amount of tabs, in order to be | ||
|
@@ -243,11 +253,27 @@ export abstract class _MatTabGroupBase extends _MatTabGroupMixinBase implements | |
} | ||
} | ||
|
||
this._subscribeToTabLabels(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed this call because I noticed that there's another one just like it a few lines above. It seems like an issue when resolving merge conflicts. |
||
this._changeDetectorRef.markForCheck(); | ||
}); | ||
} | ||
|
||
/** Listens to changes in all of the tabs. */ | ||
private _subscribeToAllTabChanges() { | ||
// Since we use a query with `descendants: true` to pick up the tabs, we may end up catching | ||
// some that are inside of nested tab groups. We filter them out manually by checking that | ||
// the closest group to the tab is the current one. | ||
this._allTabs.changes | ||
.pipe(startWith(this._allTabs)) | ||
.subscribe((tabs: QueryList<MatTab>) => { | ||
this._tabs.reset(tabs.filter(tab => { | ||
// @breaking-change 10.0.0 Remove null check for `_closestTabGroup` | ||
// once it becomes a required parameter in MatTab. | ||
return !tab._closestTabGroup || tab._closestTabGroup === this; | ||
crisbeto marked this conversation as resolved.
Show resolved
Hide resolved
|
||
})); | ||
this._tabs.notifyOnChanges(); | ||
}); | ||
} | ||
|
||
ngOnDestroy() { | ||
this._tabsSubscription.unsubscribe(); | ||
this._tabLabelSubscription.unsubscribe(); | ||
|
@@ -363,14 +389,18 @@ export abstract class _MatTabGroupBase extends _MatTabGroupMixinBase implements | |
// tslint:disable-next-line:validate-decorators | ||
changeDetection: ChangeDetectionStrategy.Default, | ||
inputs: ['color', 'disableRipple'], | ||
providers: [{ | ||
provide: MAT_TAB_GROUP, | ||
useExisting: MatTabGroup | ||
}], | ||
host: { | ||
'class': 'mat-tab-group', | ||
'[class.mat-tab-group-dynamic-height]': 'dynamicHeight', | ||
'[class.mat-tab-group-inverted-header]': 'headerPosition === "below"', | ||
}, | ||
}) | ||
export class MatTabGroup extends _MatTabGroupBase { | ||
@ContentChildren(MatTab) _tabs: QueryList<MatTab>; | ||
@ContentChildren(MatTab, {descendants: true}) _allTabs: QueryList<MatTab>; | ||
@ViewChild('tabBodyWrapper', {static: false}) _tabBodyWrapper: ElementRef; | ||
@ViewChild('tabHeader', {static: false}) _tabHeader: MatTabGroupBaseHeader; | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is all duplicated from what's in
material/
. Do we have a reason for choosing this approach?Was it too much work or is there a blocker to trying to export something from
material/
tests that could be re-used in thematerial-experimental/mdc-x
tests?