MCPcopy Create free account
hub / github.com/UI5/webcomponents / _getFirstMatchingItem

Method _getFirstMatchingItem

packages/main/src/ComboBox.ts:1251–1272  ·  view source on GitHub ↗
(current: string)

Source from the content-addressed store, hash-verified

1249 }
1250
1251 _getFirstMatchingItem(current: string): IComboBoxItem | void {
1252 const allItems = this._getItems();
1253 const currentlyFocusedItem = allItems.find(item => item.focused === true);
1254
1255 if (currentlyFocusedItem?.isGroupItem) {
1256 this.value = this.filterValue;
1257 return;
1258 }
1259
1260 const matchingItems: Array<IComboBoxItem> = this._startsWithMatchingItems(current);
1261
1262 if (matchingItems.length) {
1263 let exactMatch;
1264 if (this._useSelectedValue) {
1265 exactMatch = matchingItems.find(item => item.value === (currentlyFocusedItem?.value || this.selectedValue) && item.text?.toLowerCase() === current.toLowerCase());
1266 } else {
1267 exactMatch = matchingItems.find(item => item.text?.toLowerCase() === current.toLowerCase());
1268 }
1269
1270 return exactMatch ?? matchingItems[0];
1271 }
1272 }
1273
1274 _applyAtomicValueAndSelection(item: IComboBoxItem, filterValue: string) {
1275 const value = (item && item.text) || "";

Callers 1

_handleTypeAheadMethod · 0.95

Calls 2

_getItemsMethod · 0.95

Tested by

no test coverage detected