Skip to content

fix(material/table): increase specificity on sticky selector #21403

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 1 commit into from
Jan 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/material-experimental/mdc-table/table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
@include mat-private-table-flex-styles();

.mat-mdc-table-sticky {
@include vendor-prefixes.position-sticky;
// Note that the table can either set this class or an inline style to make something sticky.
// We set the style as `!important` so that we get an identical specificity in both cases
// and to avoid cases where user styles have a higher specificity.
@include vendor-prefixes.position-sticky($important: true);
}

// MDC Table applies `table-layout: fixed`, but this is a backwards incompatible
Expand Down
6 changes: 3 additions & 3 deletions src/material/core/style/_vendor-prefixes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
backface-visibility: $value;
}

@mixin position-sticky {
position: -webkit-sticky;
position: sticky;
@mixin position-sticky($important: false) {
position: -webkit-sticky #{if($important, '!important', '')};
position: sticky #{if($important, '!important', '')};
}
/* stylelint-enable */
5 changes: 4 additions & 1 deletion src/material/table/table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ th.mat-header-cell, td.mat-cell, td.mat-footer-cell {
}

.mat-table-sticky {
@include vendor-prefixes.position-sticky;
// Note that the table can either set this class or an inline style to make something sticky.
// We set the style as `!important` so that we get an identical specificity in both cases
// and to avoid cases where user styles have a higher specificity.
@include vendor-prefixes.position-sticky($important: true);
}

.mat-table-fixed-layout {
Expand Down