Skip to content

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

Merged
merged 3 commits into from
Dec 17, 2020

Conversation

annieyw
Copy link
Contributor

@annieyw annieyw commented Nov 10, 2020

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

@annieyw annieyw added P2 The issue is important to a large percentage of users, with a workaround G This is is related to a Google internal issue labels Nov 10, 2020
@google-cla google-cla bot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Nov 10, 2020
@@ -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]',
Copy link
Member

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?

Copy link
Member

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.

@annieyw annieyw force-pushed the mdc-mat-table-selector branch from c929ea1 to 2f399a8 Compare November 13, 2020 21:31
@annieyw annieyw requested a review from jelbourn November 13, 2020 21:31
@annieyw annieyw force-pushed the mdc-mat-table-selector branch from 2f399a8 to bb85910 Compare December 2, 2020 19:26
@annieyw annieyw added the target: patch This PR is targeted for the next patch release label Dec 2, 2020
@annieyw
Copy link
Contributor Author

annieyw commented Dec 3, 2020

Added selectors for cells and rows
Added CSS for flexbox based styles

@annieyw annieyw force-pushed the mdc-mat-table-selector branch from 3e6bc2f to dfabefb Compare December 4, 2020 00:45
@annieyw annieyw force-pushed the mdc-mat-table-selector branch 3 times, most recently from 5c9e15e to 2393c88 Compare December 4, 2020 19:48
@annieyw annieyw force-pushed the mdc-mat-table-selector branch from 2393c88 to 391891b Compare December 7, 2020 19:01
@annieyw
Copy link
Contributor Author

annieyw commented Dec 7, 2020

For some reason CI didn't run.
Renamed mixin and added clarifying comments.

Copy link
Member

@crisbeto crisbeto left a 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 {
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

@jelbourn jelbourn left a 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

@annieyw annieyw force-pushed the mdc-mat-table-selector branch from 391891b to 18125b7 Compare December 7, 2020 20:33
@annieyw annieyw added the action: merge The PR is ready for merge by the caretaker label Dec 7, 2020
@mmalerba mmalerba merged commit f0f3748 into angular:master Dec 17, 2020
mmalerba pushed a commit that referenced this pull request Dec 17, 2020
* 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)
crisbeto added a commit to crisbeto/material2 that referenced this pull request Dec 23, 2020
…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.
@annieyw annieyw deleted the mdc-mat-table-selector branch December 29, 2020 06:54
annieyw pushed a commit that referenced this pull request Jan 6, 2021
…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.
annieyw pushed a commit that referenced this pull request Jan 6, 2021
…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)
wagnermaciel pushed a commit to wagnermaciel/components that referenced this pull request Jan 14, 2021
…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
wagnermaciel pushed a commit to wagnermaciel/components that referenced this pull request Jan 14, 2021
…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.
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jan 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement G This is is related to a Google internal issue P2 The issue is important to a large percentage of users, with a workaround target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants