citation dialog: stricter non-sql item search (#5109)

While filtering selected/open/cited items, include
items that match EVERY word from the search string,
as opposed to items that match ANY of the searched words.

Fixes: #5099
This commit is contained in:
abaevbog 2025-03-14 04:33:08 -07:00 • committed by GitHub
parent a49e4e5449
commit 583fbf4e95
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -269,11 +269,13 @@ export class CitationDialogSearchHandler {
let itemStr = item.getCreators()
.map(creator => creator.firstName + " " + creator.lastName)
.concat([item.getField("title"), item.getField("date", true, true).substr(0, 4)])
.join(" ");
.join(" ")
.toLowerCase();
// See if words match
for (let split of splits) {
if (itemStr.toLowerCase().includes(split)) matchedItems.add(item);
// Include items that match every word that was typed
let allMatch = splits.every(split => itemStr.includes(split));
if (allMatch) {
matchedItems.add(item);
}
}
return Array.from(matchedItems);