MCPcopy Create free account
hub / github.com/angular/components / focus

Method focus

src/material/chips/chip-listbox.ts:230–244  ·  view source on GitHub ↗

* Focuses the first selected chip in this chip listbox, or the first non-disabled chip when there * are no selected chips.

()

Source from the content-addressed store, hash-verified

228 * are no selected chips.
229 */
230 override focus(): void {
231 if (this.disabled) {
232 return;
233 }
234
235 const firstSelectedChip = this._getFirstSelectedChip();
236
237 if (firstSelectedChip && !firstSelectedChip.disabled) {
238 firstSelectedChip.focus();
239 } else if (this._chips.length > 0) {
240 this._keyManager.setFirstItemActive();
241 } else {
242 this._elementRef.nativeElement.focus();
243 }
244 }
245
246 /**
247 * Implemented as part of ControlValueAccessor.

Callers

nothing calls this directly

Calls 3

_getFirstSelectedChipMethod · 0.95
setFirstItemActiveMethod · 0.80
focusMethod · 0.65

Tested by

no test coverage detected