diff --git a/README.md b/README.md index 16793f398c85..f405b0cfbd73 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Material Design for Angular +# Material Design for Angular test [![npm version](https://badge.fury.io/js/%40angular%2Fmaterial.svg)](https://www.npmjs.com/package/%40angular%2Fmaterial) [![Build status](https://circleci.com/gh/angular/material2.svg?style=svg)](https://circleci.com/gh/angular/material2) [![Gitter](https://badges.gitter.im/angular/material2.svg)](https://gitter.im/angular/material2?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) diff --git a/src/lib/sort/sort.spec.ts b/src/lib/sort/sort.spec.ts index ffe8e34ef1ad..304336d948d1 100644 --- a/src/lib/sort/sort.spec.ts +++ b/src/lib/sort/sort.spec.ts @@ -403,12 +403,20 @@ function testSingleColumnSortDirectionSequence(fixture: ComponentFixture { + let actualSequence = expectedSequence.map((currentSequence) => { component.sort(id); + // Check that the sort event's active sort is consistent with the MatSort - expect(component.matSort.active).toBe(id); - expect(component.latestSortEvent.active).toBe(id); + if (currentSequence) { + expect(component.matSort.active).toBe(id); + expect(component.latestSortEvent.active).toBe(id); + } else { + // For empty sequence the mat sort active should be empty + expect(component.matSort.active).toBe(''); + expect(component.latestSortEvent.active).toBe(''); + } + // Check that the sort event's direction is consistent with the MatSort expect(component.matSort.direction).toBe(component.latestSortEvent.direction); diff --git a/src/lib/sort/sort.ts b/src/lib/sort/sort.ts index 2c4167b80b98..87ca2b73df4d 100644 --- a/src/lib/sort/sort.ts +++ b/src/lib/sort/sort.ts @@ -74,8 +74,8 @@ export class MatSort extends _MatSortMixinBase /** Used to notify any child components listening to state changes. */ readonly _stateChanges = new Subject(); - /** The id of the most recently sorted MatSortable. */ - @Input('matSortActive') active: string; + /** The id of the sorted MatSortable. */ + @Input('matSortActive') active: string = ''; /** * The direction to set when an MatSortable is initially sorted. @@ -137,7 +137,9 @@ export class MatSort extends _MatSortMixinBase } else { this.direction = this.getNextSortDirection(sortable); } - + if (!this.direction) { + this.active = ''; + } this.sortChange.emit({active: this.active, direction: this.direction}); }