[Table] Sort arrows are not rendered properly in tabs
Bug, feature request, or proposal:
BUG Plunker: https://plnkr.co/edit/Idc73Kn0ViLI4Qpsp98g?p=preview
When you set your sort by default as ASC or DESC like that:
@ViewChild(MatSort) mdSort: MatSort;
ngOnInit() {this.mdSort.start = 'desc';}
The arrow is just ugly ( 2 times on 3 ). If you click again on the sort icon, it's pretty :)
BTW: Under IE11 it's always ugly. Same issue or not I don't know
What is the current behavior?

What is the expected behavior?

Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Angular 4.4.3 OS: Windows 7 Pro 64 bits TS: 2.4.1 Material: 2.0.0-beta.11 Browser: Chrome V60
Is there anything else we should know?
Nothing #
I was able to reproduce the issue and I suspect what is happening here is that you are setting an invalid direction (e.g. ascending instead of asc)
Plunker to show issue: https://plnkr.co/edit/vf61Yr6tvDtOlKRr9zeN?p=preview
Can you verify that this was the issue?
Adding PR #7378 that will throw an error if the direction is invalid.
Hi
Good try, but I think it's not the problem.
In fact, I found something interesting. It's when I use a <md-tab> and if my <md-table> is not in the first tab (loaded on the load of the page), the initialization of arrow is bad. Sorry I didn't have the time to do a plunker now ( if you don't understand, I will try to do it begining with yours ) but the idea is something like that:
<mat-tab-group *ngIf="accountExist">
<mat-tab label="{{'USER' | translate}}">
<mat-card fxLayout="column">
<mat-card-content>
<app-info-user></app-info-user> // my first <md-table> is inside this component
</mat-card-content>
</mat-card>
</mat-tab>
<mat-tab label="{{'FAMILY' | translate}}">
<mat-card fxLayout="column">
<mat-card-content>
<app-families-user></app-families-user> // my second <md-table> is inside this component
</mat-card-content>
</mat-card>
</mat-tab>
</mat-tab-group>
The second table "families" will have a ugly arrow even with with a sort "asc" or "desc"
@andrewseguin , Have you seen my previous message, why this issue is closed ?
It's not the same problem, so the solution mentioned in your PR will throw only the error but I will continue to get this error because the name "asc" is correct. For me, it's just link to the <md-table> which is included in a <md-tab> :)
Regards
NB: I will try to do a plunkr
Hey yeah - let's open this back up to figure out what's going on. Sounds like perhaps animations isn't firing off.
Definitely try and get a plunker going so we can dive into this. Thanks
This is the plunker :)
https://plnkr.co/edit/Idc73Kn0ViLI4Qpsp98g?p=preview
Go on the second tab => "family"
Great thanks for the repro. Looks like the states are being set properly but the animations framework isn't animating the arrow. I'll talk to the core animations guy to see if we can dive into this and see why it's not triggering.
Hello, any news about this bug ? :)
Coming soon - looks like this is similar to a wider issue with tabs not playing nice with Angular's content projection. In short, components in tabs are initialized without actually being on the DOM, which breaks for some animations (e.g. expansion panel). Sorry for the wait on this
@andrewseguin, don't be sorry. I just asking the status about the issue even if I'm sure, there are some others issues (high priority) which need to be fixed ASAP. BTW, thank you for the explanations :)
Still an issue on Angular 5.2.2 and Material 5.1.0
Keep an eye on https://github.com/angular/material2/pull/8921 for the fix. When it's merged then you can make it so that your tabs load lazily which means Angular animations will work correctly for content in tabs
It's a very very very bad bug for performance (@angular/material^5.2.0) It occured in mat-tabs, so the single solution is to hide these arrows why simply not to use images? It's simple and it will work
.mat-sort-header-arrow {
display: none !important;
}
Using 6.0.0 Beta and lazily-loaded tabs "fixes" the issue but it shouldn't be necessary (also, using lazy tabs is not necessarily wanted depending on the app)...
I found a workaround for this:
The first time I change to the tab with the table, I call a method which does the following:
table.ngOnDestroy(); dataSource = new DataSource(data); // This is needed because ngOnDestroy disconnects the data source. table.ngOnInit();
Note that table is the MatTable object and dataSource is bound to the table: <mat-table [dataSource]="dataSource" matSort>
It's not a good solution and kind of a hack, but it works for me. Maybe this helps some other people too.
@sielver not working unfortunately

In gif i have tried to show what is the real problem
@androidovshchik I've had it working on my end. Not an ideal solution but no glitch to be seen.
See here for an example for wrapping tabs within <ng-template matTabContent>.
edit: fixed url
@sielver solution is working(lazy loading) nicely, but put the mat-table in a separate new component, put a flag with *ngIf on the component tag, when you changeTab{ mat-tab-group(selectedTabChange) } to current turn on the flag. If you don't want to make a new component and want to use it on same component then @VangelisAlSghir works fine but inti/destroy is not a good solution
+1, waiting for a clean solution or fixes
+1 still exists on 5.2.4 when table is wrapped in *ngIf:

<div *ngIf="expanded" @expandInOut>
<mat-divider class="kd-on-top"></mat-divider>
<mat-card-content class="kd-card-content"
[ngClass]="{'kd-card-content-table': role === 'table'}">
...
<ng-content select="[content]"></ng-content>
...
</mat-card-content>
...
</div>
@maciaszczykm
Wrapping the table with *ngIf is equal to use <ng-template matTabContent>.
I'm agree with @hoangnguyen208, prefer waiting a clean solution.