Allows for programmatic focusing of the chip.
()
| 346 | |
| 347 | /** Allows for programmatic focusing of the chip. */ |
| 348 | focus(): void { |
| 349 | if (!this.disabled) { |
| 350 | // If `focus` is called before `ngAfterViewInit`, we won't have access to the primary action. |
| 351 | // This can happen if the consumer tries to focus a chip immediately after it is added. |
| 352 | // Queue the method to be called again on init. |
| 353 | if (this.primaryAction) { |
| 354 | this.primaryAction.focus(); |
| 355 | } else { |
| 356 | this._pendingFocus = true; |
| 357 | } |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | /** Gets the action that contains a specific target node. */ |
| 362 | _getSourceAction(target: Node): MatChipAction | undefined { |