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

Method _handleItemNavigation

packages/main/src/ComboBox.ts:915–952  ·  view source on GitHub ↗
(e: KeyboardEvent, indexOfItem: number, isForward: boolean)

Source from the content-addressed store, hash-verified

913 }
914
915 _handleItemNavigation(e: KeyboardEvent, indexOfItem: number, isForward: boolean) {
916 const allItems = this._getItems();
917
918 const currentItem: IComboBoxItem = allItems[indexOfItem];
919 const isGroupItem = currentItem && currentItem.isGroupItem;
920 const nextItem = isForward ? allItems[indexOfItem + 1] : allItems[indexOfItem - 1];
921
922 if ((!this.open) && ((isGroupItem && !nextItem) || (!isGroupItem && !currentItem))) {
923 return;
924 }
925
926 this._clearFocus();
927
928 if (this.open) {
929 this._itemFocused = true;
930 this.value = isGroupItem ? "" : currentItem.text!;
931 this.selectedValue = isGroupItem ? undefined : currentItem.value;
932 this.focused = false;
933
934 currentItem.focused = true;
935 } else {
936 this.focused = true;
937 this.value = isGroupItem ? nextItem.text! : currentItem.text!;
938 this.selectedValue = currentItem.value;
939 currentItem.focused = false;
940 }
941
942 this._announceSelectedItem(indexOfItem);
943 this._scrollToItem(indexOfItem);
944
945 if (isGroupItem && this.open) {
946 return;
947 }
948 // autocomplete
949 this._handleTypeAhead(this.value, this.open ? this._userTypedValue : "");
950
951 this.fireDecoratorEvent("input");
952 }
953
954 _handleTypeAhead(value: string, filterValue: string) {
955 const item = this._getFirstMatchingItem(value);

Callers 7

_handleArrowDownMethod · 0.95
_handleArrowUpMethod · 0.95
_handlePageUpMethod · 0.95
_handlePageDownMethod · 0.95
_handleHomeMethod · 0.95
_handleEndMethod · 0.95
_keydownMethod · 0.95

Calls 5

_getItemsMethod · 0.95
_clearFocusMethod · 0.95
_announceSelectedItemMethod · 0.95
_scrollToItemMethod · 0.95
_handleTypeAheadMethod · 0.95

Tested by

no test coverage detected