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

Method highlightEffect

src/aria/private/combobox/combobox.ts:221–238  ·  view source on GitHub ↗

Highlights the currently selected item in the combobox.

()

Source from the content-addressed store, hash-verified

219
220 /** Highlights the currently selected item in the combobox. */
221 highlightEffect() {
222 const value = this.value();
223 const inlineSuggestion = this.inlineSuggestion();
224
225 const isDeleting = untracked(() => this.isDeleting());
226 const isFocused = untracked(() => this.isFocused());
227 const isExpanded = this.isExpanded();
228
229 if (!inlineSuggestion || !isFocused || !isExpanded || isDeleting) return;
230
231 const inputEl = this.element() as HTMLInputElement;
232 const isHighlightable = inlineSuggestion.toLowerCase().startsWith(value.toLowerCase());
233
234 if (isHighlightable) {
235 inputEl.value = value + inlineSuggestion.slice(value.length);
236 inputEl.setSelectionRange(value.length, inlineSuggestion.length);
237 }
238 }
239
240 /** Relays keyboard events to the popup. */
241 keyboardEventRelayEffect() {

Callers 2

constructorMethod · 0.80
combobox.spec.tsFile · 0.80

Calls 4

isFocusedMethod · 0.65
isExpandedMethod · 0.65
valueMethod · 0.45
elementMethod · 0.45

Tested by

no test coverage detected