Starts the focus monitoring process on the chip.
()
| 402 | |
| 403 | /** Starts the focus monitoring process on the chip. */ |
| 404 | private _monitorFocus() { |
| 405 | this._focusMonitor.monitor(this._elementRef, true).subscribe(origin => { |
| 406 | const hasFocus = origin !== null; |
| 407 | |
| 408 | if (hasFocus !== this._hasFocusInternal) { |
| 409 | this._hasFocusInternal = hasFocus; |
| 410 | |
| 411 | if (hasFocus) { |
| 412 | this._onFocus.next({chip: this}); |
| 413 | } else { |
| 414 | // When animations are enabled, Angular may end up removing the chip from the DOM a little |
| 415 | // earlier than usual, causing it to be blurred and throwing off the logic in the chip list |
| 416 | // that moves focus to the next item. To work around the issue, we defer marking the chip |
| 417 | // as not focused until after the next render. |
| 418 | this._changeDetectorRef.markForCheck(); |
| 419 | setTimeout(() => this._ngZone.run(() => this._onBlur.next({chip: this}))); |
| 420 | } |
| 421 | } |
| 422 | }); |
| 423 | } |
| 424 | } |
no test coverage detected