Skip to content

Commit

Permalink
fix(tabs): group alignment propagating to nested groups (angular#19037)
Browse files Browse the repository at this point in the history
The selector that applies the alignment to the tab header was too broad which meant that it was applying to any nested tab groups.

Fixes angular#19035.
  • Loading branch information
crisbeto authored Apr 20, 2020
1 parent 1cf4048 commit 5224ac2
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 10 deletions.
8 changes: 5 additions & 3 deletions src/material-experimental/mdc-tabs/_tabs-common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,18 @@ $mat-tab-animation-duration: 500ms !default;
}

// Structural styles for the element that wraps the paginated header items.
@mixin mat-mdc-paginated-tab-header-item-wrapper {
@mixin mat-mdc-paginated-tab-header-item-wrapper($parent) {
display: flex;
flex: 1 0 auto;

// We need to set the parent here explicitly, in order to prevent the alignment
// from any parent tab groups from propagating down to the children when nesting.
// Note that these are used as inputs so they shouldn't be changed to `mat-mdc-`.
[mat-align-tabs='center'] & {
[mat-align-tabs='center'] > #{$parent} & {
justify-content: center;
}

[mat-align-tabs='end'] & {
[mat-align-tabs='end'] > #{$parent} & {
justify-content: flex-end;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/material-experimental/mdc-tabs/tab-header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
}

.mat-mdc-tab-labels {
@include mat-mdc-paginated-tab-header-item-wrapper;
@include mat-mdc-paginated-tab-header-item-wrapper('.mat-mdc-tab-header');
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@include mat-mdc-paginated-tab-header;

.mat-mdc-tab-links {
@include mat-mdc-paginated-tab-header-item-wrapper;
@include mat-mdc-paginated-tab-header-item-wrapper('.mat-mdc-tab-link-container');
}

.mat-mdc-tab-link-container {
Expand Down
8 changes: 5 additions & 3 deletions src/material/tabs/_tabs-common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,16 @@ $mat-tab-animation-duration: 500ms !default;
}

// Structural styles for the element that wraps the paginated header items.
@mixin paginated-tab-header-item-wrapper {
@mixin paginated-tab-header-item-wrapper($parent) {
display: flex;

[mat-align-tabs='center'] & {
// We need to set the parent here explicitly, in order to prevent the alignment
// from any parent tab groups from propagating down to the children when nesting.
[mat-align-tabs='center'] > #{$parent} & {
justify-content: center;
}

[mat-align-tabs='end'] & {
[mat-align-tabs='end'] > #{$parent} & {
justify-content: flex-end;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/material/tabs/tab-header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
}

.mat-tab-labels {
@include paginated-tab-header-item-wrapper;
@include paginated-tab-header-item-wrapper('.mat-tab-header');
}

.mat-tab-label-container {
Expand Down
2 changes: 1 addition & 1 deletion src/material/tabs/tab-nav-bar/tab-nav-bar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@include paginated-tab-header;

.mat-tab-links {
@include paginated-tab-header-item-wrapper;
@include paginated-tab-header-item-wrapper('.mat-tab-link-container');
}

.mat-ink-bar {
Expand Down

0 comments on commit 5224ac2

Please sign in to comment.