Skip to content
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

feat(material-experimental/mdc-table): add mat-table selector #20994

Merged
merged 3 commits into from Dec 17, 2020

Conversation

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 G labels Nov 10, 2020
@annieyw annieyw requested a review from andrewseguin as a code owner Nov 10, 2020
@google-cla google-cla bot added the cla: yes 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

@crisbeto crisbeto Nov 10, 2020

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

@jelbourn jelbourn Nov 25, 2020

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 requested a review from jelbourn Nov 13, 2020
@annieyw annieyw added the target: patch label Dec 2, 2020
@annieyw
Copy link
Author

@annieyw 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 3 times, most recently from 5c9e15e to 2393c88 Compare Dec 4, 2020
@annieyw
Copy link
Author

@annieyw 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

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

@crisbeto crisbeto Dec 7, 2020

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

@annieyw annieyw Dec 7, 2020

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

@crisbeto crisbeto Dec 7, 2020

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

@jelbourn jelbourn Dec 7, 2020

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

@crisbeto crisbeto Dec 7, 2020

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

@jelbourn jelbourn Dec 9, 2020

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

LGTM, add merge-ready when ready

src/material-experimental/mdc-table/table.scss Outdated Show resolved Hide resolved
src/material/table/BUILD.bazel Outdated Show resolved Hide resolved
@annieyw annieyw added the merge ready label Dec 7, 2020
@mmalerba mmalerba merged commit f0f3748 into angular:master Dec 17, 2020
16 checks passed
mmalerba pushed a commit that referenced this issue 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 issue 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 Dec 29, 2020
annieyw pushed a commit that referenced this issue 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 issue 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 issue 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 issue 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

@angular-automatic-lock-bot angular-automatic-lock-bot bot commented Jan 29, 2021

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
cla: yes G merge ready P2 target: patch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants