Skip to content

fix(material/sort): animation not working correctly when activated on focus #21339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 17, 2020
Merged
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
13 changes: 9 additions & 4 deletions src/material/sort/sort-header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export class MatSortHeader extends _MatSortHeaderMixinBase
private _disableClear: boolean;

constructor(public _intl: MatSortHeaderIntl,
changeDetectorRef: ChangeDetectorRef,
private _changeDetectorRef: ChangeDetectorRef,
// `MatSort` is not optionally injected, but just asserted manually w/ better error.
// tslint:disable-next-line: lightweight-tokens
@Optional() public _sort: MatSort,
Expand Down Expand Up @@ -171,7 +171,7 @@ export class MatSortHeader extends _MatSortHeaderMixinBase
this._setAnimationTransitionState({fromState: 'active', toState: this._arrowDirection});
}

changeDetectorRef.markForCheck();
_changeDetectorRef.markForCheck();
});
}

Expand All @@ -191,8 +191,13 @@ export class MatSortHeader extends _MatSortHeaderMixinBase
ngAfterViewInit() {
// We use the focus monitor because we also want to style
// things differently based on the focus origin.
this._focusMonitor.monitor(this._elementRef, true)
.subscribe(origin => this._setIndicatorHintVisible(!!origin));
this._focusMonitor.monitor(this._elementRef, true).subscribe(origin => {
const newState = !!origin;
if (newState !== this._showIndicatorHint) {
this._setIndicatorHintVisible(newState);
this._changeDetectorRef.markForCheck();
}
});
}

ngOnDestroy() {
Expand Down
2 changes: 1 addition & 1 deletion tools/public_api_guard/material/sort.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export declare class MatSortHeader extends _MatSortHeaderMixinBase implements Ca
set disableClear(v: boolean);
id: string;
start: 'asc' | 'desc';
constructor(_intl: MatSortHeaderIntl, changeDetectorRef: ChangeDetectorRef, _sort: MatSort, _columnDef: MatSortHeaderColumnDef, _focusMonitor: FocusMonitor, _elementRef: ElementRef<HTMLElement>);
constructor(_intl: MatSortHeaderIntl, _changeDetectorRef: ChangeDetectorRef, _sort: MatSort, _columnDef: MatSortHeaderColumnDef, _focusMonitor: FocusMonitor, _elementRef: ElementRef<HTMLElement>);
_getAriaSortAttribute(): "none" | "ascending" | "descending";
_getArrowDirectionState(): string;
_getArrowViewState(): string;
Expand Down