fix: keep workspace rename double-click reachable
This commit is contained in:
BIN
docs/pr-media/1698/workspace-double-click-rename.png
Normal file
BIN
docs/pr-media/1698/workspace-double-click-rename.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 104 KiB |
@@ -5653,6 +5653,7 @@ function _renderTreeItems(container, entries, depth){
|
||||
// Name
|
||||
const nameEl=document.createElement('span');
|
||||
nameEl.className='file-name';nameEl.textContent=item.name;nameEl.title=t('double_click_rename');
|
||||
nameEl.onclick=(e)=>e.stopPropagation();
|
||||
nameEl.ondblclick=(e)=>{
|
||||
e.stopPropagation();
|
||||
// For directories, double-click navigates (breadcrumb view)
|
||||
|
||||
22
tests/test_workspace_tree_rename.py
Normal file
22
tests/test_workspace_tree_rename.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
UI_JS = (REPO_ROOT / "static" / "ui.js").read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def test_workspace_file_name_click_stops_before_dblclick_rename():
|
||||
"""Clicking a file name must not bubble to the row open handler before dblclick rename."""
|
||||
name_start = UI_JS.index("const nameEl=document.createElement('span');")
|
||||
dblclick_idx = UI_JS.index("nameEl.ondblclick=(e)=>", name_start)
|
||||
click_idx = UI_JS.find("nameEl.onclick=(e)=>e.stopPropagation();", name_start, dblclick_idx)
|
||||
|
||||
assert click_idx != -1, (
|
||||
"workspace file-tree name span must stop click propagation before its dblclick "
|
||||
"rename handler so the row openFile() click does not win the first click"
|
||||
)
|
||||
|
||||
|
||||
def test_workspace_file_row_click_still_opens_file_preview():
|
||||
"""Only the name span should swallow clicks; the rest of the file row still opens preview."""
|
||||
assert "el.onclick=async()=>openFile(item.path);" in UI_JS
|
||||
Reference in New Issue
Block a user