Skip to content

Commit

Permalink
fix(material/sort): fix undefined object access (#22634)
Browse files Browse the repository at this point in the history
(cherry picked from commit 68600b8)
  • Loading branch information
chunghha authored and andrewseguin committed May 19, 2021
1 parent fe4df3f commit 54e832d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/material/sort/sort-header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`. */
Expand Down Expand Up @@ -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 = '';
Expand Down Expand Up @@ -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.
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 @@ -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<MatSortDefaultOptions>;
Expand Down

0 comments on commit 54e832d

Please sign in to comment.