File tree Expand file tree Collapse file tree 4 files changed +33
-1
lines changed
tools/public_api_guard/lib Expand file tree Collapse file tree 4 files changed +33
-1
lines changed Original file line number Diff line number Diff line change 1111
1212 <!-- Disable animations while a current animation is running -->
1313 < div class ="mat-sort-header-arrow "
14+ *ngIf ="_renderArrow() "
1415 [@arrowOpacity] ="_getArrowViewState() "
1516 [@arrowPosition] ="_getArrowViewState() "
1617 [@allowChildren] ="_getArrowDirectionState() "
Original file line number Diff line number Diff line change @@ -289,4 +289,9 @@ export class MatSortHeader extends _MatSortHeaderMixinBase
289289
290290 return this . _sort . direction == 'asc' ? 'ascending' : 'descending' ;
291291 }
292+
293+ /** Whether the arrow inside the sort header should be rendered. */
294+ _renderArrow ( ) {
295+ return ! this . _isDisabled ( ) || this . _isSorted ( ) ;
296+ }
292297}
Original file line number Diff line number Diff line change @@ -31,7 +31,6 @@ import {
3131
3232describe ( 'MatSort' , ( ) => {
3333 let fixture : ComponentFixture < SimpleMatSortApp > ;
34-
3534 let component : SimpleMatSortApp ;
3635
3736 beforeEach ( async ( ( ) => {
@@ -384,6 +383,32 @@ describe('MatSort', () => {
384383 expect ( button . getAttribute ( 'aria-label' ) ) . toBe ( 'Sort all of the things' ) ;
385384 } )
386385 ) ;
386+
387+ it ( 'should not render the arrow if sorting is disabled for that column' , fakeAsync ( ( ) => {
388+ const sortHeaderElement = fixture . nativeElement . querySelector ( '#defaultA' ) ;
389+
390+ // Switch sorting to a different column before asserting.
391+ component . sort ( 'defaultB' ) ;
392+ fixture . componentInstance . disabledColumnSort = true ;
393+ fixture . detectChanges ( ) ;
394+ tick ( ) ;
395+ fixture . detectChanges ( ) ;
396+
397+ expect ( sortHeaderElement . querySelector ( '.mat-sort-header-arrow' ) ) . toBeFalsy ( ) ;
398+ } ) ) ;
399+
400+ it ( 'should render the arrow if a disabled column is being sorted by' , fakeAsync ( ( ) => {
401+ const sortHeaderElement = fixture . nativeElement . querySelector ( '#defaultA' ) ;
402+
403+ component . sort ( 'defaultA' ) ;
404+ fixture . componentInstance . disabledColumnSort = true ;
405+ fixture . detectChanges ( ) ;
406+ tick ( ) ;
407+ fixture . detectChanges ( ) ;
408+
409+ expect ( sortHeaderElement . querySelector ( '.mat-sort-header-arrow' ) ) . toBeTruthy ( ) ;
410+ } ) ) ;
411+
387412} ) ;
388413
389414/**
Original file line number Diff line number Diff line change @@ -71,6 +71,7 @@ export declare class MatSortHeader extends _MatSortHeaderMixinBase implements Ca
7171 _handleClick ( ) : void ;
7272 _isDisabled ( ) : boolean ;
7373 _isSorted ( ) : boolean ;
74+ _renderArrow ( ) : boolean ;
7475 _setAnimationTransitionState ( viewState : ArrowViewStateTransition ) : void ;
7576 _setIndicatorHintVisible ( visible : boolean ) : void ;
7677 _updateArrowDirection ( ) : void ;
You can’t perform that action at this time.
0 commit comments