Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/material/sort/sort.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,12 +455,18 @@ function testSingleColumnSortDirectionSequence(
component.matSort.direction = '';

// Run through the sequence to confirm the order
const actualSequence = expectedSequence.map(() => {
const 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);
Expand Down
6 changes: 4 additions & 2 deletions src/material/sort/sort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class MatSort implements OnChanges, OnDestroy, OnInit {
readonly _stateChanges = new Subject<void>();

/** The id of the most recently sorted MatSortable. */
@Input('matSortActive') active: string;
@Input('matSortActive') active: string = '';

/**
* The direction to set when an MatSortable is initially sorted.
Expand Down Expand Up @@ -165,7 +165,9 @@ export class MatSort implements OnChanges, OnDestroy, OnInit {
} else {
this.direction = this.getNextSortDirection(sortable);
}

if (!this.direction) {
this.active = '';
}
this.sortChange.emit({active: this.active, direction: this.direction});
}

Expand Down
Loading