Add expandOnSingleClick
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@tp/tp-tree-nav",
|
||||
"version": "1.2.1",
|
||||
"version": "1.3.0",
|
||||
"description": "",
|
||||
"main": "tp-tree-nav.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user