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

Method _onkeydown

packages/compat/src/TableRow.ts:213–254  ·  view source on GitHub ↗
(e: KeyboardEvent)

Source from the content-addressed store, hash-verified

211 }
212
213 _onkeydown(e: KeyboardEvent) {
214 const activeElement = getActiveElement() as HTMLElement;
215 const itemActive = this.type === TableRowType.Active;
216 const isSingleSelect = this.isSingleSelect;
217 const itemSelectable = isSingleSelect || this.isMultiSelect;
218 const isRowFocused = this._activeElementHasAttribute("ui5-table-row");
219 const target = e.target as HTMLElement;
220 const checkboxPressed = target.classList.contains("ui5-multi-select-checkbox");
221 const rowElements = Array.from(this.shadowRoot!.querySelectorAll("tr") || []);
222 const elements = rowElements.map(getLastTabbableElement).filter(Boolean);
223 const lastFocusableElement = elements.pop();
224
225 if (isTabNext(e) && activeElement === (lastFocusableElement || this.root)) {
226 this.fireDecoratorEvent("forward-after", { target: activeElement });
227 }
228
229 if (isTabPrevious(e) && activeElement === this.root) {
230 this.fireDecoratorEvent("forward-before", { target: activeElement });
231 }
232
233 if (isSpace(e) && target.tagName.toLowerCase() === "tr") {
234 e.preventDefault();
235 }
236
237 if (isRowFocused && !checkboxPressed) {
238 if ((isSpace(e) && itemSelectable) || (isEnter(e) && isSingleSelect)) {
239 this.fireDecoratorEvent("selection-requested", { row: this });
240 }
241
242 if (isEnter(e) && itemActive) {
243 this.fireDecoratorEvent("row-click", { row: this });
244 if (!isSingleSelect) {
245 this.activate();
246 }
247 }
248 }
249
250 if (isF7(e)) {
251 e.preventDefault();
252 this.fireDecoratorEvent("f7-pressed", { row: this });
253 }
254 }
255
256 _onkeyup(e: KeyboardEvent) {
257 if (isSpace(e) || isEnter(e)) {

Callers

nothing calls this directly

Calls 9

activateMethod · 0.95
getActiveElementFunction · 0.85
isTabNextFunction · 0.85
isTabPreviousFunction · 0.85
isSpaceFunction · 0.85
isEnterFunction · 0.85
isF7Function · 0.85
containsMethod · 0.80

Tested by

no test coverage detected