Skip to content

Commit 2a7ec52

Browse files
committed
comments
1 parent dc5d97e commit 2a7ec52

File tree

4 files changed

+18
-15
lines changed

4 files changed

+18
-15
lines changed

src/lib/sort/sort-header.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="mat-sort-header-container"
1+
<div class="mat-sort-header-container" type="button"
22
[class.mat-sort-header-position-before]="arrowPosition == 'before'">
33
<button class="mat-sort-header-button"
44
[attr.aria-label]="_intl.sortButtonLabel(id)">

src/lib/sort/sort-header.scss

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@ $mat-sort-header-arrow-container-size: 10px;
33
$mat-sort-header-arrow-pointer-length: 8px;
44
$mat-sort-header-arrow-thickness: 2px;
55

6-
:host {
7-
cursor: pointer;
8-
}
9-
106
.mat-sort-header-container {
117
display: flex;
8+
cursor: pointer;
129
}
1310

1411
.mat-sort-header-position-before {
@@ -51,15 +48,15 @@ $mat-sort-header-arrow-thickness: 2px;
5148
}
5249

5350
.mat-sort-header-stem {
54-
background: black;
51+
background: currentColor;
5552
transform: rotate(135deg);
5653
height: $mat-sort-header-arrow-container-size;
5754
width: $mat-sort-header-arrow-thickness;
5855
margin: auto;
5956
}
6057

6158
.mat-sort-header-pointer-left {
62-
background: black;
59+
background: currentColor;
6360
width: $mat-sort-header-arrow-thickness;
6461
height: $mat-sort-header-arrow-pointer-length;
6562
position: absolute;
@@ -68,7 +65,7 @@ $mat-sort-header-arrow-thickness: 2px;
6865
}
6966

7067
.mat-sort-header-pointer-right {
71-
background: black;
68+
background: currentColor;
7269
width: $mat-sort-header-arrow-pointer-length;
7370
height: $mat-sort-header-arrow-thickness;
7471
position: absolute;

src/lib/sort/sort-header.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {Component, Input, Optional} from '@angular/core';
9+
import {
10+
ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, Optional,
11+
ViewEncapsulation
12+
} from '@angular/core';
1013
import {MdSort, MdSortable} from './sort';
1114
import {MdSortIntl} from './sort-intl';
1215
import {CdkColumnDef} from '../core/data-table/cell';
@@ -31,7 +34,9 @@ import {getMdSortHeaderNotContainedWithinMdSortError} from './sort-errors';
3134
host: {
3235
'(click)': '_sort.sort(this)',
3336
'[class.mat-sort-header-sorted]': '_isSorted()',
34-
}
37+
},
38+
encapsulation: ViewEncapsulation.None,
39+
changeDetection: ChangeDetectionStrategy.OnPush,
3540
})
3641
export class MdSortHeader implements MdSortable {
3742
/**
@@ -62,12 +67,15 @@ export class MdSortHeader implements MdSortable {
6267
get _id() { return this.id; }
6368
set _id(v: string) { this.id = v; }
6469

65-
constructor(@Optional() public _sort: MdSort,
66-
public _intl: MdSortIntl,
70+
constructor(private _intl: MdSortIntl,
71+
private _changeDetectorRef: ChangeDetectorRef,
72+
@Optional() public _sort: MdSort,
6773
@Optional() public _cdkColumnDef: CdkColumnDef) {
6874
if (!_sort) {
6975
throw getMdSortHeaderNotContainedWithinMdSortError();
7076
}
77+
78+
_sort.mdSortChange.subscribe(() => _changeDetectorRef.markForCheck());
7179
}
7280

7381
ngOnInit() {
@@ -84,6 +92,6 @@ export class MdSortHeader implements MdSortable {
8492

8593
/** Whether this MdSortHeader is currently sorted in either ascending or descending order. */
8694
_isSorted() {
87-
return this._sort.active == this.id && this._sort.direction != '';
95+
return this._sort.active == this.id && this._sort.direction;
8896
}
8997
}

src/lib/sort/sort.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ export class MdSort {
6767
/**
6868
* Register function to be used by the contained MdSortables. Adds the MdSortable to the
6969
* collection of MdSortables.
70-
* @docs-private
7170
*/
7271
register(sortable: MdSortable) {
7372
if (!sortable.id) {
@@ -83,7 +82,6 @@ export class MdSort {
8382
/**
8483
* Unregister function to be used by the contained MdSortables. Removes the MdSortable from the
8584
* collection of contained MdSortables.
86-
* @docs-private
8785
*/
8886
unregister(sortable: MdSortable) {
8987
this.sortables.delete(sortable.id);

0 commit comments

Comments
 (0)