citation dialog: Enter adds row when only 1 match (#5106)

In library mode when there are no selected/open/cited items,
Enter keypress from input will add the first row of itemTree
into the citation only if it is the only row.

Fixes: #5098
This commit is contained in:
abaevbog 2025-03-12 18:25:41 -07:00 • committed by GitHub
parent 38188ff7d0
commit ea71725e7f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1207,8 +1207,8 @@ const IOManager = {
let items = selectedIDs.map(id => SearchHandler.getItem(id));
IOManager.addItemsToCitation(items);
}
// if there are no selected items in library mode and something was searched for add the first row from items table
else if (currentLayout.type == "library" && libraryLayout.itemsView.rowCount > 0 && input.value.length) {
// in library mode, if there are no selected/open/cited items but there is a single match in itemTree, add that one matching item
else if (currentLayout.type == "library" && libraryLayout.itemsView.rowCount === 1 && input.value.length) {
let firstRowID = libraryLayout.itemsView.getRow(0).ref.id;
IOManager.addItemsToCitation(Zotero.Items.get(firstRowID));
}