Skip to content

Commit 86ec493

Browse files
andrewseguinjelbourn
authored andcommitted
compat(sort): add mat compatible sort event (#6611)
1 parent 9043466 commit 86ec493

File tree

7 files changed

+15
-12
lines changed

7 files changed

+15
-12
lines changed

src/demo-app/table/person-data-source.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class PersonDataSource extends DataSource<any> {
1515
connect(): Observable<UserData[]> {
1616
const displayDataChanges = [
1717
this._paginator.page,
18-
this._sort.mdSortChange,
18+
this._sort.sortChange,
1919
this._peopleDatabase.dataChange
2020
];
2121
return Observable.merge(...displayDataChanges).map(() => {

src/lib/sort/sort-header.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export class MdSortHeader implements MdSortable {
9191
throw getMdSortHeaderNotContainedWithinMdSortError();
9292
}
9393

94-
this._rerenderSubscription = merge(_sort.mdSortChange, _intl.changes).subscribe(() => {
94+
this._rerenderSubscription = merge(_sort.sortChange, _intl.changes).subscribe(() => {
9595
changeDetectorRef.markForCheck();
9696
});
9797
}

src/lib/sort/sort.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,10 @@ function testSingleColumnSortDirectionSequence(fixture: ComponentFixture<SimpleM
200200
[mdSortDirection]="direction"
201201
[mdSortDisableClear]="disableClear"
202202
(mdSortChange)="latestSortEvent = $event">
203-
<div id="defaultSortHeaderA" #defaultSortHeaderA md-sort-header="defaultSortHeaderA"> A </div>
204-
<div id="defaultSortHeaderB" #defaultSortHeaderB md-sort-header="defaultSortHeaderB"> B </div>
205-
<div id="overrideStart" md-sort-header="overrideStart" start="desc"> D </div>
206-
<div id="overrideDisableClear" md-sort-header="overrideDisableClear" disableClear> E </div>
203+
<div id="defaultSortHeaderA" #defaultSortHeaderA md-sort-header="defaultSortHeaderA"> A</div>
204+
<div id="defaultSortHeaderB" #defaultSortHeaderB md-sort-header="defaultSortHeaderB"> B</div>
205+
<div id="overrideStart" md-sort-header="overrideStart" start="desc"> D</div>
206+
<div id="overrideDisableClear" md-sort-header="overrideDisableClear" disableClear> E</div>
207207
</div>
208208
`
209209
})

src/lib/sort/sort.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ export class MdSort {
7272
set _matSortDisableClear(v) { this.disableClear = v; }
7373

7474
/** Event emitted when the user changes either the active sort or sort direction. */
75-
@Output() mdSortChange = new EventEmitter<Sort>();
75+
@Output('mdSortChange') readonly sortChange = new EventEmitter<Sort>();
76+
77+
@Output('matSortChange')
78+
get _matSortChange(): EventEmitter<Sort> { return this.sortChange; }
7679

7780
/**
7881
* Register function to be used by the contained MdSortables. Adds the MdSortable to the
@@ -106,7 +109,7 @@ export class MdSort {
106109
this.direction = this.getNextSortDirection(sortable);
107110
}
108111

109-
this.mdSortChange.next({active: this.active, direction: this.direction});
112+
this.sortChange.next({active: this.active, direction: this.direction});
110113
}
111114

112115
/** Returns the next sort direction of the active sortable, checking for potential overrides. */

src/material-examples/table-http/table-http-example.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ export class ExampleDataSource extends DataSource<GithubIssue> {
8383
/** Connect function called by the table to retrieve one stream containing the data to render. */
8484
connect(): Observable<GithubIssue[]> {
8585
const displayDataChanges = [
86-
this.sort.mdSortChange,
86+
this.sort.sortChange,
8787
this.paginator.page
8888
];
8989

9090
// If the user changes the sort order, reset back to the first page.
91-
this.sort.mdSortChange.subscribe(() => this.paginator.pageIndex = 0);
91+
this.sort.sortChange.subscribe(() => this.paginator.pageIndex = 0);
9292

9393
return Observable.merge(...displayDataChanges)
9494
.startWith(null)

src/material-examples/table-overview/table-overview-example.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ export class ExampleDataSource extends DataSource<any> {
140140
// Listen for any changes in the base data, sorting, filtering, or pagination
141141
const displayDataChanges = [
142142
this._exampleDatabase.dataChange,
143-
this._sort.mdSortChange,
143+
this._sort.sortChange,
144144
this._filterChange,
145145
this._paginator.page,
146146
];

src/material-examples/table-sorting/table-sorting-example.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export class ExampleDataSource extends DataSource<any> {
9090
connect(): Observable<UserData[]> {
9191
const displayDataChanges = [
9292
this._exampleDatabase.dataChange,
93-
this._sort.mdSortChange,
93+
this._sort.sortChange,
9494
];
9595

9696
return Observable.merge(...displayDataChanges).map(() => {

0 commit comments

Comments
 (0)