diff --git a/assets/index.css b/assets/index.css index 6046a8813..7ecd4d3bd 100644 --- a/assets/index.css +++ b/assets/index.css @@ -176,7 +176,7 @@ body { padding-left: 2px; } -.paths-table tbody tr:hover { +.paths-table tbody tr:not(.selected):hover { background-color: transparent; } diff --git a/assets/index.js b/assets/index.js index 6e70f1fa2..20f6f855d 100644 --- a/assets/index.js +++ b/assets/index.js @@ -1530,25 +1530,17 @@ function initFileTree() { openedIcon: iconOpen, closedIcon: iconClose, }); - $("#tree").bind("tree.click", function (event) { - const node = event.node; + + // when open tree node, load children + $("#tree").on("tree.open", function (e) { + const node = e.node; + mylog("tree open node", node); selectedPath = node.id || notChoosePath; - document.getElementById("selectedPath").textContent = `已选择路径:${selectedPath}` - // by source code, single node children is use name as label + document.getElementById("selectedPath").textContent = `已选择路径:${selectedPath.replace(getDefaultPathPrefix(), "")}` if (node.children && node.children.length > 0 && !hasLoadingChildren(node)) { - if (node.is_open) { - $('#tree').tree('closeNode', node); - } else { - $('#tree').tree('openNode', node); - } return; } if (node.name === treeNoChildren) { - if (node.is_open) { - $('#tree').tree('closeNode', node); - } else { - $('#tree').tree('openNode', node); - } return; } mylog("tree click node", node) @@ -1570,6 +1562,19 @@ function initFileTree() { $('#tree').tree('openNode', node); }) }); + + // when click tree node, open or close it. + // also set selectedPath. + $("#tree").bind("tree.click", function (event) { + const node = event.node; + selectedPath = node.id || notChoosePath; + document.getElementById("selectedPath").textContent = `已选择路径:${selectedPath.replace(getDefaultPathPrefix(), "")}` + if (node.is_open) { + $('#tree').tree('closeNode', node); + } else { + $('#tree').tree('openNode', node); + } + }); } /**