File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -459,12 +459,19 @@ function testSingleColumnSortDirectionSequence(
459459 component . matSort . direction = '' ;
460460
461461 // Run through the sequence to confirm the order
462- let actualSequence = expectedSequence . map ( ( ) => {
462+ let actualSequence = expectedSequence . map ( ( currentSequence ) => {
463463 component . sort ( id ) ;
464464
465465 // Check that the sort event's active sort is consistent with the MatSort
466- expect ( component . matSort . active ) . toBe ( id ) ;
467- expect ( component . latestSortEvent . active ) . toBe ( id ) ;
466+ if ( currentSequence ) {
467+ expect ( component . matSort . active ) . toBe ( id ) ;
468+ expect ( component . latestSortEvent . active ) . toBe ( id ) ;
469+ } else {
470+ // For empty sequence the mat sort active should be empty
471+ expect ( component . matSort . active ) . toBe ( '' ) ;
472+ expect ( component . latestSortEvent . active ) . toBe ( '' ) ;
473+ }
474+
468475
469476 // Check that the sort event's direction is consistent with the MatSort
470477 expect ( component . matSort . direction ) . toBe ( component . latestSortEvent . direction ) ;
Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ export class MatSort extends _MatSortMixinBase
8989 readonly _stateChanges = new Subject < void > ( ) ;
9090
9191 /** The id of the most recently sorted MatSortable. */
92- @Input ( 'matSortActive' ) active : string ;
92+ @Input ( 'matSortActive' ) active : string = '' ;
9393
9494 /**
9595 * The direction to set when an MatSortable is initially sorted.
@@ -160,7 +160,9 @@ export class MatSort extends _MatSortMixinBase
160160 } else {
161161 this . direction = this . getNextSortDirection ( sortable ) ;
162162 }
163-
163+ if ( ! this . direction ) {
164+ this . active = '' ;
165+ }
164166 this . sortChange . emit ( { active : this . active , direction : this . direction } ) ;
165167 }
166168
You can’t perform that action at this time.
0 commit comments