Ignore collection-tree activation when multiple rows are selected

Pressing Enter (or double-clicking) edited the focused row -- renaming a
collection or opening the saved-search/feed editor -- even with several rows
selected. Activation acts on one row, so ignore it for multi-selection.
This commit is contained in:
Dan Stillman 2026-06-16 12:11:24 -04:00
parent ee24c0b468
commit 9e324fe62b
2 changed files with 19 additions and 0 deletions

View file

@ -245,6 +245,11 @@ var CollectionTree = class CollectionTree extends LibraryTree {
}
handleActivate = (event, indices) => {
// Activation (rename collection, edit saved search/feed, open library) acts on
// a single row, so ignore it when multiple rows are selected
if (this.selection.count > 1) {
return;
}
let index = indices[0];
let treeRow = this.getRow(index);
if (treeRow.isCollection() && this.editable && this.selection.focused == index) {

View file

@ -709,6 +709,20 @@ describe("Zotero.CollectionTree", function () {
});
});
describe("#handleActivate()", function () {
it("shouldn't start editing when multiple collections are selected", async function () {
let c1 = await createDataObject('collection');
let c2 = await createDataObject('collection');
await cv.selectByID("C" + c1.id);
cv.selection.toggleSelect(cv.getRowIndexByID("C" + c2.id));
assert.equal(cv.selection.count, 2);
cv.handleActivate(new Event('keydown'), [cv.selection.focused]);
assert.notOk(cv._editing);
});
});
describe("#onDrop()", function () {
/**
* Simulate a drag and drop