-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(material-experimental/mdc-table): add mat-table selector #20994
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
Conversation
@@ -16,7 +16,7 @@ import { | |||
import {_DisposeViewRepeaterStrategy, _VIEW_REPEATER_STRATEGY} from '@angular/cdk/collections'; | |||
|
|||
@Component({ | |||
selector: 'table[mat-table]', | |||
selector: 'mat-table table[mat-table]', |
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.
Shouldn't it be mat-table, table[mat-table]
? The current selector is looking for tables inside a mat-table
element.
Also it seems like there are other directives that are only scoped to table elements, like MatHeaderCell
, MatCell
etc. I wonder whether @andrewseguin did this intentionally?
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.
Additionally, the element-based APIs will need additional CSS to align with the flexbox-based style of the older version.
c929ea1
to
2f399a8
Compare
2f399a8
to
bb85910
Compare
Added selectors for cells and rows |
3e6bc2f
to
dfabefb
Compare
5c9e15e
to
2393c88
Compare
…d tables styles into private mixin
2393c88
to
391891b
Compare
For some reason CI didn't run. |
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.
LGTM, aside from the one question.
$mat-row-horizontal-padding: 24px; | ||
|
||
// Only use tag name selectors here since the styles are shared between MDC and non-MDC | ||
@mixin mat-private-table-flex-styles { |
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.
Looking through this again, do you think that we should make these selectors a bit more specific? Currently mat-table {}
will match both the MDC and non-MDC elements which could interfere with each other. We could change it to something like mat-table.mat-mdc-table
, but I'm not familiar enough to know whether it'll make much of a difference.
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.
The reason for extracting the flex styles into a mixin is so that both MDC and non-MDC table can use the styles
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.
Wouldn't we want the MDC version to be using MDC's styles though? Otherwise it's basically a duplicate of our current table.
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.
MDC only has native table styles. The flexbox-based table is an Angular special.
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.
Wouldn't we still want to make it work using MDC's styles? Not necessarily in this PR, but we can work with the MDC team to split their styles up into more granular mixins so we can apply it to our flexbox table too.
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.
I had been assuming the only styles we were applying exclusively to the flex table were the actual flexbox styles. If there are styles common between them, we should just use the appropriate css classes for those.
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.
LGTM, add merge-ready when ready
…ex based tables styles into private mixin
391891b
to
18125b7
Compare
* feat(material-experimental/mdc-table): add mat-table selector * fix(material-experimental/mdc-table): extract variables and flex based tables styles into private mixin * fixup! fix(material-experimental/mdc-table): extract variables and flex based tables styles into private mixin (cherry picked from commit f0f3748)
…is initialized The MDC-based table tries to add a class to its internal `tbody` element and it assumes that it's always going to find it. The assumption used to be correct since we only supported native `table` elements for the MDC implementation, however as of angular#20994 we also support flexbox-based ones which throw an error, because they don't have a `tbody`. These changes add a check to prevent the error and include a couple of sanity tests to catch issues like this in the future. I've also reworked the tests so that they use the MDC-based `MatPaginator` and `MatTableDataSource`, instead of the base ones.
…is initialized (#21428) The MDC-based table tries to add a class to its internal `tbody` element and it assumes that it's always going to find it. The assumption used to be correct since we only supported native `table` elements for the MDC implementation, however as of #20994 we also support flexbox-based ones which throw an error, because they don't have a `tbody`. These changes add a check to prevent the error and include a couple of sanity tests to catch issues like this in the future. I've also reworked the tests so that they use the MDC-based `MatPaginator` and `MatTableDataSource`, instead of the base ones.
…is initialized (#21428) The MDC-based table tries to add a class to its internal `tbody` element and it assumes that it's always going to find it. The assumption used to be correct since we only supported native `table` elements for the MDC implementation, however as of #20994 we also support flexbox-based ones which throw an error, because they don't have a `tbody`. These changes add a check to prevent the error and include a couple of sanity tests to catch issues like this in the future. I've also reworked the tests so that they use the MDC-based `MatPaginator` and `MatTableDataSource`, instead of the base ones. (cherry picked from commit 2255b66)
…r#20994) * feat(material-experimental/mdc-table): add mat-table selector * fix(material-experimental/mdc-table): extract variables and flex based tables styles into private mixin * fixup! fix(material-experimental/mdc-table): extract variables and flex based tables styles into private mixin
…is initialized (angular#21428) The MDC-based table tries to add a class to its internal `tbody` element and it assumes that it's always going to find it. The assumption used to be correct since we only supported native `table` elements for the MDC implementation, however as of angular#20994 we also support flexbox-based ones which throw an error, because they don't have a `tbody`. These changes add a check to prevent the error and include a couple of sanity tests to catch issues like this in the future. I've also reworked the tests so that they use the MDC-based `MatPaginator` and `MatTableDataSource`, instead of the base ones.
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Have consistent selectors between original MatTable and MDC-based MatTable.
Note that the mat-table tag is used for users that are styling tables with flex as per the MatTable documentation: https://material.angular.io/components/table/overview#tables-with-display-flex:~:text=Tables%20with%20display%3A%20flex,-The