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

Method handleNavKeyPress

packages/main/src/ComboBox.ts:882–913  ·  view source on GitHub ↗
(e: KeyboardEvent)

Source from the content-addressed store, hash-verified

880 }
881
882 handleNavKeyPress(e: KeyboardEvent) {
883 const allItems = this._getItems();
884
885 if (this.focused && (isHome(e) || isEnd(e)) && this.value) {
886 return;
887 }
888
889 const isOpen = this.open;
890 const currentItem = allItems.find(item => {
891 return item.selected || item.focused;
892 });
893
894 const indexOfItem = currentItem ? allItems.indexOf(currentItem) : -1;
895 e.preventDefault();
896
897 if (this.focused && isOpen && (isUp(e) || isPageUp(e) || isPageDown(e))) {
898 return;
899 }
900
901 this._isKeyNavigation = true;
902
903 if (
904 e.key === "ArrowDown"
905 || e.key === "ArrowUp"
906 || e.key === "PageUp"
907 || e.key === "PageDown"
908 || e.key === "Home"
909 || e.key === "End"
910 ) {
911 this[`_handle${e.key}`](e, indexOfItem);
912 }
913 }
914
915 _handleItemNavigation(e: KeyboardEvent, indexOfItem: number, isForward: boolean) {
916 const allItems = this._getItems();

Callers 2

_keydownMethod · 0.95

Calls 6

_getItemsMethod · 0.95
isHomeFunction · 0.85
isEndFunction · 0.85
isUpFunction · 0.85
isPageUpFunction · 0.85
isPageDownFunction · 0.85

Tested by

no test coverage detected