Add expandOnSingleClick

This commit is contained in:
2025-12-18 09:14:41 +01:00
parent 209249806b
commit c9d6f98de2
2 changed files with 8 additions and 2 deletions

View File

@@ -255,6 +255,7 @@ export class TpTreeNav extends Position(LitElement) {
applyStates: { type: Function },
emptyMessage: { type: String },
showActions: { type: Boolean },
expandOnSingleClick: { type: Boolean },
expandOnDoubleClick: { type: Boolean },
selectOnRightClick: { type: Boolean },
allowDragAndDrop: { type: Boolean },
@@ -299,6 +300,7 @@ export class TpTreeNav extends Position(LitElement) {
this.applyStates = null;
this.emptyMessage = 'No items';
this.showActions = false;
this.expandOnSingleClick = false;
this.expandOnDoubleClick = false;
this.selectOnRightClick = false;
this.allowDragAndDrop = false;
@@ -362,7 +364,7 @@ export class TpTreeNav extends Position(LitElement) {
}
_onRowClick(item, originalEvent) {
const isDouble = this.expandOnDoubleClick && originalEvent?.detail === 2;
const isDouble = this.expandOnDoubleClick && !this.expandOnSingleClick && originalEvent?.detail === 2;
if (this.manageState) {
const pathStr = item.path.join('/');
@@ -394,6 +396,10 @@ export class TpTreeNav extends Position(LitElement) {
this._toggleExpand(item, 'double-click', originalEvent);
}
if (this.expandOnSingleClick) {
this._toggleExpand(item, 'single-click', originalEvent);
}
this.dispatchEvent(new CustomEvent('node-click', {
detail: { node: item.node, path: item.path, originalEvent },
bubbles: true,