6
6
* found in the LICENSE file at https://angular.dev/license
7
7
*/
8
8
9
- import { _IdGenerator , FocusMonitor } from '@angular/cdk/a11y' ;
9
+ import { FocusMonitor , _IdGenerator } from '@angular/cdk/a11y' ;
10
10
import { BACKSPACE , DELETE } from '@angular/cdk/keycodes' ;
11
+ import { _CdkPrivateStyleLoader , _VisuallyHiddenLoader } from '@angular/cdk/private' ;
11
12
import { DOCUMENT } from '@angular/common' ;
12
13
import {
13
14
ANIMATION_MODULE_TYPE ,
@@ -30,21 +31,19 @@ import {
30
31
QueryList ,
31
32
ViewChild ,
32
33
ViewEncapsulation ,
33
- afterNextRender ,
34
34
booleanAttribute ,
35
35
inject ,
36
36
} from '@angular/core' ;
37
37
import {
38
- _StructuralStylesLoader ,
39
38
MAT_RIPPLE_GLOBAL_OPTIONS ,
40
39
MatRippleLoader ,
41
40
RippleGlobalOptions ,
41
+ _StructuralStylesLoader ,
42
42
} from '@angular/material/core' ;
43
43
import { Subject , Subscription , merge } from 'rxjs' ;
44
44
import { MatChipAction } from './chip-action' ;
45
45
import { MatChipAvatar , MatChipRemove , MatChipTrailingIcon } from './chip-icons' ;
46
46
import { MAT_CHIP , MAT_CHIP_AVATAR , MAT_CHIP_REMOVE , MAT_CHIP_TRAILING_ICON } from './tokens' ;
47
- import { _CdkPrivateStyleLoader , _VisuallyHiddenLoader } from '@angular/cdk/private' ;
48
47
49
48
/** Represents an event fired on an individual `mat-chip`. */
50
49
export interface MatChipEvent {
@@ -391,11 +390,10 @@ export class MatChip implements OnInit, AfterViewInit, AfterContentInit, DoCheck
391
390
} else {
392
391
// When animations are enabled, Angular may end up removing the chip from the DOM a little
393
392
// earlier than usual, causing it to be blurred and throwing off the logic in the chip list
394
- // that moves focus not the next item. To work around the issue, we defer marking the chip
393
+ // that moves focus to the next item. To work around the issue, we defer marking the chip
395
394
// as not focused until after the next render.
396
- afterNextRender ( ( ) => this . _ngZone . run ( ( ) => this . _onBlur . next ( { chip : this } ) ) , {
397
- injector : this . _injector ,
398
- } ) ;
395
+ this . _changeDetectorRef . markForCheck ( ) ;
396
+ setTimeout ( ( ) => this . _ngZone . run ( ( ) => this . _onBlur . next ( { chip : this } ) ) ) ;
399
397
}
400
398
}
401
399
} ) ;
0 commit comments