Skip to content

Commit 0611a0d

Browse files
authored
fix(material-experimental/mdc-table): add background color; disable hover styles; fix sticky columns (#22723)
* fix(material-experimental/mdc-table): add background color; disable hover styles; fix sticky columns * fix(material-experimental/mdc-table): lint * fix(material-experimental/mdc-table): extra line
1 parent ba06cd8 commit 0611a0d

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/material-experimental/mdc-table/_table-theme.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@use 'sass:map';
12
@use '@material/theme/theme-color' as mdc-theme-color;
23
@use '@material/data-table/data-table' as mdc-data-table;
34
@use '@material/data-table/data-table-theme' as mdc-data-table-theme;
@@ -41,6 +42,11 @@
4142
mdc-data-table-theme.$sort-icon-color: $orig-sort-icon-color;
4243
mdc-data-table-theme.$sort-icon-active-color: $orig-sort-icon-active-color;
4344
mdc-data-table-theme.$stroke-color: $orig-stroke-color;
45+
46+
.mat-mdc-table {
47+
$background: map.get($config, background);
48+
background: theming.get-color-from-palette($background, 'card');
49+
}
4450
}
4551

4652
@mixin typography($config-or-theme) {

src/material-experimental/mdc-table/table.scss

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
// change since the table did not previously apply it.
1818
// TODO: Add a mixin to MDC to set the layout instead of including this override,
1919
// see this issue: https://github.com/material-components/material-components-web/issues/6412
20-
.mdc-data-table__table {
20+
.mat-mdc-table {
2121
table-layout: auto;
2222
}
2323

@@ -27,3 +27,18 @@
2727
mat-row.mat-mdc-row, mat-header-row.mat-mdc-header-row, mat-footer-row.mat-mdc-footer-row {
2828
border-bottom: none;
2929
}
30+
31+
// Cells need to inherit their background in order to overlap each other when sticky.
32+
// The background needs to be inherited from the table, tbody/tfoot, row
33+
// (already set in MDC), and cell.
34+
.mat-mdc-table tbody, .mat-mdc-table tfoot,
35+
.mat-mdc-cell, .mat-mdc-footer-cell {
36+
background: inherit;
37+
}
38+
39+
// Disable hover styling while MDC uses an opacity for its color.
40+
// When the hover style is used with sticky cells, the opacity shows the cells overlapping.
41+
.mat-mdc-table .mat-mdc-row:hover,
42+
.mat-mdc-table .mat-mdc-footer-row:hover {
43+
background-color: inherit;
44+
}

0 commit comments

Comments
 (0)