show message in list mode on no search results

This commit is contained in:
Bogdan Abaev 2026-04-24 12:32:45 -07:00
parent 7e89aa9c54
commit 870856d7a6
3 changed files with 36 additions and 7 deletions

View file

@ -1322,8 +1322,16 @@ class ListLayout extends Layout {
}
}
// Hide padding of list layout if there is not a single item to show
_id("list-layout").classList.toggle("empty", this._listRows.length === 0);
// Insert message when there are no matching results - only
// when window resizing is not skipped, meaning library search has ran
if (!skipWindowResize) {
if (this._listRows.length === 0) {
this._listRows.push(new ListRow({
kind: "empty",
ref: { activeSearch: SearchHandler.searchValue.length > 0 },
}));
}
}
// Push per-row heights to the virtualized table's _customRowHeightMap
this._table.updateCustomRowHeights(
@ -1436,6 +1444,15 @@ class ListLayout extends Layout {
divider.className = "divider";
div.appendChild(divider);
}
else if (row.kind === "empty") {
let message = doc.createElement("div");
message.className = "empty-message";
let suffix = row.ref.activeSearch ? "-searching" : "";
message.textContent = Zotero.getString(
`integration-citationDialog-list-message-${DIALOG_STATE.type}${suffix}`
);
div.appendChild(message);
}
else {
div.setAttribute("data-l10n-id", "integration-citationDialog-aria-item-list");
let node = this.createItemNode(row.ref);

View file

@ -49,6 +49,10 @@ integration-citationDialog-lib-message-annotations = { $search ->
[true] No items with annotations match the current search
*[other] No selected or open items with annotations
}
integration-citationDialog-list-message-citation = No selected, open, or cited items
integration-citationDialog-list-message-citation-searching = No items match the current search
integration-citationDialog-list-message-add-note = No selected or open notes
integration-citationDialog-list-message-add-note-searching = No notes match the current search
integration-citationDialog-settings-keepSorted = Keep sources sorted
integration-citationDialog-btn-settings =
.title = { general-open-settings }

View file

@ -431,6 +431,19 @@
border-bottom: 1px solid var(--fill-quinary);
}
// Empty-state message -- emitted as a single row when no search
// results are available.
.row > .empty-message {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
padding: 0 16px;
text-align: center;
font-size: 1rem;
color: var(--fill-secondary);
}
// Section header -- emitted as its own row at the start of every section.
.row > .header {
font-weight: 700;
@ -538,11 +551,6 @@
}
}
}
&.empty {
#list-layout-wrapper .virtualized-table-body {
padding: 0;
}
}
}
#bottom-area-wrapper {