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 11
11
12
12
<!-- Disable animations while a current animation is running -->
13
13
< div class ="mat-sort-header-arrow "
14
+ *ngIf ="_renderArrow() "
14
15
[@arrowOpacity] ="_getArrowViewState() "
15
16
[@arrowPosition] ="_getArrowViewState() "
16
17
[@allowChildren] ="_getArrowDirectionState() "
Original file line number Diff line number Diff line change @@ -289,4 +289,9 @@ export class MatSortHeader extends _MatSortHeaderMixinBase
289
289
290
290
return this . _sort . direction == 'asc' ? 'ascending' : 'descending' ;
291
291
}
292
+
293
+ /** Whether the arrow inside the sort header should be rendered. */
294
+ _renderArrow ( ) {
295
+ return ! this . _isDisabled ( ) || this . _isSorted ( ) ;
296
+ }
292
297
}
Original file line number Diff line number Diff line change @@ -31,7 +31,6 @@ import {
31
31
32
32
describe ( 'MatSort' , ( ) => {
33
33
let fixture : ComponentFixture < SimpleMatSortApp > ;
34
-
35
34
let component : SimpleMatSortApp ;
36
35
37
36
beforeEach ( async ( ( ) => {
@@ -384,6 +383,32 @@ describe('MatSort', () => {
384
383
expect ( button . getAttribute ( 'aria-label' ) ) . toBe ( 'Sort all of the things' ) ;
385
384
} )
386
385
) ;
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
+
387
412
} ) ;
388
413
389
414
/**
Original file line number Diff line number Diff line change @@ -71,6 +71,7 @@ export declare class MatSortHeader extends _MatSortHeaderMixinBase implements Ca
71
71
_handleClick ( ) : void ;
72
72
_isDisabled ( ) : boolean ;
73
73
_isSorted ( ) : boolean ;
74
+ _renderArrow ( ) : boolean ;
74
75
_setAnimationTransitionState ( viewState : ArrowViewStateTransition ) : void ;
75
76
_setIndicatorHintVisible ( visible : boolean ) : void ;
76
77
_updateArrowDirection ( ) : void ;
You can’t perform that action at this time.
0 commit comments