From 54e832d080a5699d13e37760c7a00309629e899c Mon Sep 17 00:00:00 2001 From: chunghha Date: Wed, 19 May 2021 09:59:04 -0500 Subject: [PATCH] fix(material/sort): fix undefined object access (#22634) (cherry picked from commit 68600b8f4301bd56e6411f2ac1ba5637691ed650) --- src/material/sort/sort-header.ts | 6 +++--- tools/public_api_guard/material/sort.d.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/material/sort/sort-header.ts b/src/material/sort/sort-header.ts index f42c9392eecb..0e6fb5378e6a 100644 --- a/src/material/sort/sort-header.ts +++ b/src/material/sort/sort-header.ts @@ -54,7 +54,7 @@ export type ArrowViewState = SortDirection | 'hint' | 'active'; */ export interface ArrowViewStateTransition { fromState?: ArrowViewState; - toState: ArrowViewState; + toState?: ArrowViewState; } /** Column definition associated with a `MatSortHeader`. */ @@ -112,7 +112,7 @@ export class MatSortHeader extends _MatSortHeaderMixinBase * position through the animation. If animations are currently disabled, the fromState is removed * so that there is no animation displayed. */ - _viewState: ArrowViewStateTransition; + _viewState: ArrowViewStateTransition = { }; /** The direction the arrow should be facing according to the current state. */ _arrowDirection: SortDirection = ''; @@ -224,7 +224,7 @@ export class MatSortHeader extends _MatSortHeaderMixinBase * no animation appears. */ _setAnimationTransitionState(viewState: ArrowViewStateTransition) { - this._viewState = viewState; + this._viewState = viewState || { }; // If the animation for arrow position state (opacity/translation) should be disabled, // remove the fromState so that it jumps right to the toState. diff --git a/tools/public_api_guard/material/sort.d.ts b/tools/public_api_guard/material/sort.d.ts index 8b882b5396d5..93ecabbecd32 100644 --- a/tools/public_api_guard/material/sort.d.ts +++ b/tools/public_api_guard/material/sort.d.ts @@ -2,7 +2,7 @@ export declare type ArrowViewState = SortDirection | 'hint' | 'active'; export interface ArrowViewStateTransition { fromState?: ArrowViewState; - toState: ArrowViewState; + toState?: ArrowViewState; } export declare const MAT_SORT_DEFAULT_OPTIONS: InjectionToken;