From c9d6f98de2b437945ce9ec2284d3db8f8b28ba7a Mon Sep 17 00:00:00 2001 From: pk Date: Thu, 18 Dec 2025 09:14:41 +0100 Subject: [PATCH] Add expandOnSingleClick --- package.json | 2 +- tp-tree-nav.js | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2c4ab60..ea6db37 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tp/tp-tree-nav", - "version": "1.2.1", + "version": "1.3.0", "description": "", "main": "tp-tree-nav.js", "scripts": { diff --git a/tp-tree-nav.js b/tp-tree-nav.js index 4978466..e23f0a4 100644 --- a/tp-tree-nav.js +++ b/tp-tree-nav.js @@ -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,