Skip to content

Commit 54e832d

Browse files
chunghhaandrewseguin
authored andcommitted
fix(material/sort): fix undefined object access (#22634)
(cherry picked from commit 68600b8)
1 parent fe4df3f commit 54e832d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/material/sort/sort-header.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export type ArrowViewState = SortDirection | 'hint' | 'active';
5454
*/
5555
export interface ArrowViewStateTransition {
5656
fromState?: ArrowViewState;
57-
toState: ArrowViewState;
57+
toState?: ArrowViewState;
5858
}
5959

6060
/** Column definition associated with a `MatSortHeader`. */
@@ -112,7 +112,7 @@ export class MatSortHeader extends _MatSortHeaderMixinBase
112112
* position through the animation. If animations are currently disabled, the fromState is removed
113113
* so that there is no animation displayed.
114114
*/
115-
_viewState: ArrowViewStateTransition;
115+
_viewState: ArrowViewStateTransition = { };
116116

117117
/** The direction the arrow should be facing according to the current state. */
118118
_arrowDirection: SortDirection = '';
@@ -224,7 +224,7 @@ export class MatSortHeader extends _MatSortHeaderMixinBase
224224
* no animation appears.
225225
*/
226226
_setAnimationTransitionState(viewState: ArrowViewStateTransition) {
227-
this._viewState = viewState;
227+
this._viewState = viewState || { };
228228

229229
// If the animation for arrow position state (opacity/translation) should be disabled,
230230
// remove the fromState so that it jumps right to the toState.

tools/public_api_guard/material/sort.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export declare type ArrowViewState = SortDirection | 'hint' | 'active';
22

33
export interface ArrowViewStateTransition {
44
fromState?: ArrowViewState;
5-
toState: ArrowViewState;
5+
toState?: ArrowViewState;
66
}
77

88
export declare const MAT_SORT_DEFAULT_OPTIONS: InjectionToken<MatSortDefaultOptions>;

0 commit comments

Comments
 (0)