File tree Expand file tree Collapse file tree 3 files changed +20
-2
lines changed Expand file tree Collapse file tree 3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ export const config = {
24
24
'should not remove margin if initial label is set through binding' ,
25
25
'should re-add margin if label is added asynchronously' ,
26
26
'should properly update margin if label content is projected' ,
27
+ 'should transition correctly from initially checked to indeterminate' ,
27
28
28
29
// TODO: the focus origin behavior needs to be implemented in the MDC checkbox
29
30
'should not change focus origin if origin not specified' ,
Original file line number Diff line number Diff line change @@ -562,6 +562,21 @@ describe('MatCheckbox', () => {
562
562
'mat-checkbox-anim-unchecked-indeterminate' ,
563
563
) ;
564
564
} ) ) ;
565
+
566
+ it ( 'should transition correctly from initially checked to indeterminate' , ( ) => {
567
+ testComponent . isIndeterminate = false ;
568
+ testComponent . isChecked = true ;
569
+ fixture . detectChanges ( ) ;
570
+
571
+ expect ( checkboxNativeElement . className ) . not . toMatch ( / ^ m a t \- c h e c k b o x \- a n i m / g) ;
572
+
573
+ testComponent . isIndeterminate = testComponent . isChecked = true ;
574
+ fixture . detectChanges ( ) ;
575
+
576
+ expect ( checkboxNativeElement . classList ) . toContain (
577
+ 'mat-checkbox-anim-checked-indeterminate' ,
578
+ ) ;
579
+ } ) ;
565
580
} ) ;
566
581
567
582
describe ( `when MAT_CHECKBOX_CLICK_ACTION is 'check'` , ( ) => {
Original file line number Diff line number Diff line change @@ -329,7 +329,7 @@ export abstract class _MatCheckboxBase<E>
329
329
if ( oldState === newState || ! element ) {
330
330
return ;
331
331
}
332
- if ( this . _currentAnimationClass . length > 0 ) {
332
+ if ( this . _currentAnimationClass ) {
333
333
element . classList . remove ( this . _currentAnimationClass ) ;
334
334
}
335
335
@@ -435,7 +435,9 @@ export abstract class _MatCheckboxBase<E>
435
435
if ( newState === TransitionCheckState . Checked ) {
436
436
return this . _animationClasses . uncheckedToChecked ;
437
437
} else if ( newState == TransitionCheckState . Indeterminate ) {
438
- return this . _animationClasses . uncheckedToIndeterminate ;
438
+ return this . _checked
439
+ ? this . _animationClasses . checkedToIndeterminate
440
+ : this . _animationClasses . uncheckedToIndeterminate ;
439
441
}
440
442
break ;
441
443
case TransitionCheckState . Unchecked :
You can’t perform that action at this time.
0 commit comments