@@ -159,20 +159,7 @@ export class MatSortHeader extends _MatSortHeaderMixinBase
159
159
throw getSortHeaderNotContainedWithinSortError ( ) ;
160
160
}
161
161
162
- this . _rerenderSubscription = merge ( _sort . sortChange , _sort . _stateChanges , _intl . changes )
163
- . subscribe ( ( ) => {
164
- if ( this . _isSorted ( ) ) {
165
- this . _updateArrowDirection ( ) ;
166
- }
167
-
168
- // If this header was recently active and now no longer sorted, animate away the arrow.
169
- if ( ! this . _isSorted ( ) && this . _viewState && this . _viewState . toState === 'active' ) {
170
- this . _disableViewStateAnimation = false ;
171
- this . _setAnimationTransitionState ( { fromState : 'active' , toState : this . _arrowDirection } ) ;
172
- }
173
-
174
- _changeDetectorRef . markForCheck ( ) ;
175
- } ) ;
162
+ this . _handleStateChanges ( ) ;
176
163
}
177
164
178
165
ngOnInit ( ) {
@@ -243,27 +230,17 @@ export class MatSortHeader extends _MatSortHeaderMixinBase
243
230
244
231
/** Triggers the sort on this sort header and removes the indicator hint. */
245
232
_toggleOnInteraction ( ) {
246
-
247
233
this . _sort . sort ( this ) ;
248
234
249
235
// Do not show the animation if the header was already shown in the right position.
250
236
if ( this . _viewState . toState === 'hint' || this . _viewState . toState === 'active' ) {
251
237
this . _disableViewStateAnimation = true ;
252
238
}
253
-
254
- // If the arrow is now sorted, animate the arrow into place. Otherwise, animate it away into
255
- // the direction it is facing.
256
- const viewState : ArrowViewStateTransition = this . _isSorted ( ) ?
257
- { fromState : this . _arrowDirection , toState : 'active' } :
258
- { fromState : 'active' , toState : this . _arrowDirection } ;
259
- this . _setAnimationTransitionState ( viewState ) ;
260
-
261
- this . _showIndicatorHint = false ;
262
239
}
263
240
264
241
_handleClick ( ) {
265
242
if ( ! this . _isDisabled ( ) ) {
266
- this . _toggleOnInteraction ( ) ;
243
+ this . _sort . sort ( this ) ;
267
244
}
268
245
}
269
246
@@ -330,6 +307,32 @@ export class MatSortHeader extends _MatSortHeaderMixinBase
330
307
return ! this . _isDisabled ( ) || this . _isSorted ( ) ;
331
308
}
332
309
310
+ /** Handles changes in the sorting state. */
311
+ private _handleStateChanges ( ) {
312
+ this . _rerenderSubscription =
313
+ merge ( this . _sort . sortChange , this . _sort . _stateChanges , this . _intl . changes ) . subscribe ( ( ) => {
314
+ if ( this . _isSorted ( ) ) {
315
+ this . _updateArrowDirection ( ) ;
316
+
317
+ // Do not show the animation if the header was already shown in the right position.
318
+ if ( this . _viewState . toState === 'hint' || this . _viewState . toState === 'active' ) {
319
+ this . _disableViewStateAnimation = true ;
320
+ }
321
+
322
+ this . _setAnimationTransitionState ( { fromState : this . _arrowDirection , toState : 'active' } ) ;
323
+ this . _showIndicatorHint = false ;
324
+ }
325
+
326
+ // If this header was recently active and now no longer sorted, animate away the arrow.
327
+ if ( ! this . _isSorted ( ) && this . _viewState && this . _viewState . toState === 'active' ) {
328
+ this . _disableViewStateAnimation = false ;
329
+ this . _setAnimationTransitionState ( { fromState : 'active' , toState : this . _arrowDirection } ) ;
330
+ }
331
+
332
+ this . _changeDetectorRef . markForCheck ( ) ;
333
+ } ) ;
334
+ }
335
+
333
336
static ngAcceptInputType_disableClear : BooleanInput ;
334
337
static ngAcceptInputType_disabled : BooleanInput ;
335
338
}
0 commit comments