From a31cd40b9f5609aa3b17d61a9bad95bc92a4f964 Mon Sep 17 00:00:00 2001 From: Suresh918 Date: Wed, 13 Feb 2019 19:57:39 +0530 Subject: [PATCH 1/7] fix(sort): If there is no direction, setting active as empty #15169 --- src/lib/sort/sort.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/sort/sort.ts b/src/lib/sort/sort.ts index 2c4167b80b98..e9c01e8937b3 100644 --- a/src/lib/sort/sort.ts +++ b/src/lib/sort/sort.ts @@ -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}); } From d9fbf790805c9eb0aee523a7c8ba14257c1eec40 Mon Sep 17 00:00:00 2001 From: Suresh918 Date: Wed, 13 Feb 2019 20:58:53 +0530 Subject: [PATCH 2/7] sort: test case changes --- src/lib/sort/sort.spec.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib/sort/sort.spec.ts b/src/lib/sort/sort.spec.ts index ffe8e34ef1ad..0bb8fc0027a2 100644 --- a/src/lib/sort/sort.spec.ts +++ b/src/lib/sort/sort.spec.ts @@ -403,12 +403,14 @@ function testSingleColumnSortDirectionSequence(fixture: ComponentFixture { + let actualSequence = expectedSequence.map((currentSequence) => { component.sort(id); + // For empty sequence the expectedSortId should be empty + const expectedSortId = currentSequence ? 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); + expect(component.matSort.active).toBe(expectedSortId); + expect(component.latestSortEvent.active).toBe(expectedSortId); // Check that the sort event's direction is consistent with the MatSort expect(component.matSort.direction).toBe(component.latestSortEvent.direction); From 5a7154a663b73b142fd00f4dd23be198d5d92760 Mon Sep 17 00:00:00 2001 From: Suresh918 Date: Thu, 14 Feb 2019 11:11:28 +0530 Subject: [PATCH 3/7] test cases for mat sort active state for empty sequence and other sequences --- src/lib/sort/sort.spec.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/lib/sort/sort.spec.ts b/src/lib/sort/sort.spec.ts index 0bb8fc0027a2..7c35180837e1 100644 --- a/src/lib/sort/sort.spec.ts +++ b/src/lib/sort/sort.spec.ts @@ -406,11 +406,17 @@ function testSingleColumnSortDirectionSequence(fixture: ComponentFixture { component.sort(id); - // For empty sequence the expectedSortId should be empty - const expectedSortId = currentSequence ? id : ''; + // Check that the sort event's active sort is consistent with the MatSort - expect(component.matSort.active).toBe(expectedSortId); - expect(component.latestSortEvent.active).toBe(expectedSortId); + 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); From ecc18c16ab2ad8e2ec231e375ad0d085c853abfd Mon Sep 17 00:00:00 2001 From: Suresh918 Date: Thu, 14 Feb 2019 11:18:53 +0530 Subject: [PATCH 4/7] lint errors fix --- src/lib/sort/sort.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/sort/sort.spec.ts b/src/lib/sort/sort.spec.ts index 7c35180837e1..304336d948d1 100644 --- a/src/lib/sort/sort.spec.ts +++ b/src/lib/sort/sort.spec.ts @@ -408,7 +408,7 @@ function testSingleColumnSortDirectionSequence(fixture: ComponentFixture Date: Sun, 17 Feb 2019 00:11:49 +0530 Subject: [PATCH 5/7] JS doc changes for sort active field --- src/lib/sort/sort.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/sort/sort.ts b/src/lib/sort/sort.ts index e9c01e8937b3..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. From 11d943bdf005da152202ff4d97e04d345652dc97 Mon Sep 17 00:00:00 2001 From: Suresh918 Date: Thu, 25 Feb 2021 23:10:05 +0100 Subject: [PATCH 6/7] readme changed --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) From d14457c31c973864a78ab9dfd2b13bd9f472e628 Mon Sep 17 00:00:00 2001 From: Suresh918 Date: Wed, 13 Feb 2019 19:57:39 +0530 Subject: [PATCH 7/7] fix(sort): If there is no direction, setting active as empty #15169 sort: test case changes test cases for mat sort active state for empty sequence and other sequences lint errors fix JS doc changes for sort active field --- src/lib/sort/sort.spec.ts | 14 +++++++++++--- src/lib/sort/sort.ts | 8 +++++--- 2 files changed, 16 insertions(+), 6 deletions(-) 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}); }