Skip to content

fix(material/sort): fix undefined object access #22634

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
May 19, 2021
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
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