Skip to content

Commit

Permalink
fix(ui5-tree-item-custom): improved key handling (#8733)
Browse files Browse the repository at this point in the history
Previously it was impossible to properly use keyboard inside input elements nested in TreeItemCustom. Now the handling is similar to CustomListItem and input elements can be used as expected.

Fixes: #7566
plamenivanov91 authored Apr 17, 2024

Verified

This commit was signed with the committer’s verified signature.
snyk-bot Snyk bot
1 parent 2f46b63 commit 2592f58
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/main/src/TreeItemCustom.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
import property from "@ui5/webcomponents-base/dist/decorators/property.js";
import slot from "@ui5/webcomponents-base/dist/decorators/slot.js";
import { isTabNext, isTabPrevious } from "@ui5/webcomponents-base/dist/Keys.js";
import TreeItemBase from "./TreeItemBase.js";

// Template
@@ -49,6 +50,26 @@ class TreeItemCustom extends TreeItemBase {
@slot()
content!: Array<HTMLElement>;

_onkeydown(e: KeyboardEvent) {
const isTab = isTabNext(e) || isTabPrevious(e);

if (!isTab && !this.focused) {
return;
}

super._onkeydown(e);
}

_onkeyup(e: KeyboardEvent) {
const isTab = isTabNext(e) || isTabPrevious(e);

if (!isTab && !this.focused) {
return;
}

super._onkeyup(e);
}

/**
* @override
*/

0 comments on commit 2592f58

Please sign in to comment.