MCPcopy Index your code
hub / github.com/UI5/webcomponents / _focusElement

Method _focusElement

packages/main/src/TableNavigation.ts:89–110  ·  view source on GitHub ↗
(element: HTMLElement, ignoreFocusIn: boolean = true)

Source from the content-addressed store, hash-verified

87 }
88
89 _focusElement(element: HTMLElement, ignoreFocusIn: boolean = true) {
90 if (!element || element === getActiveElement()) {
91 return;
92 }
93
94 const navigationItems = this._getNavigationItemsOfGrid().flat();
95 if (navigationItems.includes(this._lastFocusedItem)) {
96 this._lastFocusedItem?.removeAttribute("tabindex");
97 }
98
99 if (navigationItems.includes(element)) {
100 element.setAttribute("tabindex", "-1");
101 this._lastFocusedItem = element;
102 }
103
104 this._ignoreFocusIn = ignoreFocusIn;
105 element.focus({ preventScroll: element === this._table._beforeElement || element === this._table._afterElement });
106 if (element instanceof HTMLInputElement) {
107 element.select();
108 }
109 this._ignoreFocusIn = false;
110 }
111
112 _focusCurrentItem() {
113 this._focusElement(this._gridWalker.getCurrent() as HTMLElement);

Callers 6

_focusCurrentItemMethod · 0.95
_handleF2Method · 0.95
_handleF7Method · 0.95
_handleTabMethod · 0.95
_handleArrowUpDownMethod · 0.95
_onKeyDownCaptureMethod · 0.95

Calls 4

getActiveElementFunction · 0.85
selectMethod · 0.80
focusMethod · 0.45

Tested by

no test coverage detected