Starts the focus monitoring process on the chip.
()
| 423 | |
| 424 | /** Starts the focus monitoring process on the chip. */ |
| 425 | private _monitorFocus() { |
| 426 | this._focusMonitor.monitor(this._elementRef, true).subscribe(origin => { |
| 427 | const hasFocus = origin !== null; |
| 428 | |
| 429 | if (hasFocus !== this._hasFocusInternal) { |
| 430 | this._hasFocusInternal = hasFocus; |
| 431 | |
| 432 | if (hasFocus) { |
| 433 | this._onFocus.next({chip: this}); |
| 434 | } else { |
| 435 | // When animations are enabled, Angular may end up removing the chip from the DOM a little |
| 436 | // earlier than usual, causing it to be blurred and throwing off the logic in the chip list |
| 437 | // that moves focus to the next item. To work around the issue, we defer marking the chip |
| 438 | // as not focused until after the next render. |
| 439 | this._changeDetectorRef.markForCheck(); |
| 440 | setTimeout(() => this._ngZone.run(() => this._onBlur.next({chip: this}))); |
| 441 | } |
| 442 | } |
| 443 | }); |
| 444 | } |
| 445 | } |
no test coverage detected