fix: 让 filetree 右键删除复用批量选择

This commit is contained in:
lix-2026
2026-05-21 15:57:28 +08:00
parent dc18ec0a60
commit 1e8f5c5816
2 changed files with 13 additions and 2 deletions
@@ -3834,6 +3834,13 @@ const SIDEBAR_TREE_JS: &str = r##"
void copyTreeContextValue(documentId || detail.assetId || detail.rowId || '', 'copy-id');
return;
}
if (action === 'delete-trash' && detail.contextKind === 'filetree') {
var selectedFileTreeRows = selectedSidebarFileTreeRows();
if (selectedFileTreeRows.length > 1) {
void deleteSelectedSidebarFileTreeRows(trigger || document.body);
return;
}
}
if (action === 'delete-trash' && isAsset) {
if (!window.confirm('' + title + '')) return;
recordFileTreeAction('delete-trash', detail);
@@ -10127,6 +10134,8 @@ mod tests {
fn sidebar_filetree_delete_keys_support_mixed_doc_and_asset_selection() {
assert!(SIDEBAR_TREE_JS.contains("function deleteSelectedSidebarFileTreeRows"));
assert!(SIDEBAR_TREE_JS.contains("event.key === 'Delete' || event.key === 'Backspace'"));
assert!(SIDEBAR_TREE_JS.contains("selectedFileTreeRows.length > 1"));
assert!(SIDEBAR_TREE_JS.contains("deleteSelectedSidebarFileTreeRows(trigger || document.body)"));
assert!(SIDEBAR_TREE_JS.contains(
"currentSourceKind() === 'local_folder' && fileTreeRowKind(row) === 'asset'"
));
@@ -130,11 +130,13 @@ async function main() {
await dialog.accept();
return message;
});
await page.locator(selectors[1]).press("Delete", {
await page.locator(selectors[1]).click({
button: "right",
timeout: UI_TIMEOUT_MS,
});
await page.locator('.mnote-tree-context-menu__item[data-action="delete-trash"]').click({ timeout: UI_TIMEOUT_MS });
const confirmText = await dialogPromise;
assert.match(confirmText, /2 个附件/, `bulk delete 确认文案应包含附件数量: ${confirmText}`);
assert.match(confirmText, /2 个附件/, `右键 bulk delete 确认文案应包含附件数量: ${confirmText}`);
await page.waitForFunction(() => document.documentElement.getAttribute("data-mnote-filetree-bulk-delete-applied") === "true", null, {
timeout: UI_TIMEOUT_MS,