mirror of
https://github.com/zotero/zotero.git
synced 2026-11-14 09:21:32 +00:00
citation dlg: fix stuck focus on preview loading (#6085)
Do not wait for preview to load cited items if io is not ready - show a loading message instead. Waiting blocks the focus from landing back in bubble-input when an item is added for the user to be able to keep typing. https://forums.zotero.org/discussion/134552/zotero-10-broke-keyboard-navigation-of-citation-dialog
This commit is contained in:
parent
8b9961f13b
commit
878f4e3bb3
4 changed files with 15 additions and 1 deletions
|
|
@ -140,6 +140,8 @@ async function onLoad() {
|
|||
if (accepted) return;
|
||||
Zotero.debug("Citation Dialog: io loaded cited data");
|
||||
await SearchHandler.refreshCitedItems();
|
||||
// Replace the loading message with the actual preview before refreshing the list
|
||||
await CitationPreview.render();
|
||||
currentLayout.refreshItemsList({ retainItemsState: true });
|
||||
if (_id("keepSorted").checked) {
|
||||
IOManager._resortItems();
|
||||
|
|
@ -2089,6 +2091,7 @@ const CitationPreview = {
|
|||
if (isEmpty) {
|
||||
_id("citation-preview-content").innerHTML = "";
|
||||
_id("citation-preview-error").hidden = true;
|
||||
_id("citation-preview-loading").hidden = true;
|
||||
}
|
||||
// The toggle button is hidden when there's no preview and is restored to its last
|
||||
// state when the preview pane appears
|
||||
|
|
@ -2104,6 +2107,14 @@ const CitationPreview = {
|
|||
if (!DIALOG_STATE.isCitingItems()) return;
|
||||
if (!CitationDataManager.items.length) return;
|
||||
if (!io.preview) return;
|
||||
// io.preview() waits for all cited data to be loaded, so show a loading
|
||||
// message until then. The preview is rendered once ioReadyPromise resolves.
|
||||
if (!ioIsReady) {
|
||||
_id("citation-preview-content").hidden = true;
|
||||
_id("citation-preview-error").hidden = true;
|
||||
_id("citation-preview-loading").hidden = false;
|
||||
return;
|
||||
}
|
||||
|
||||
CitationDataManager.updateCitationObject();
|
||||
let html;
|
||||
|
|
@ -2118,6 +2129,7 @@ const CitationPreview = {
|
|||
// Re-check after the await in case the user cleared items
|
||||
if (!CitationDataManager.items.length) return;
|
||||
let errored = html === undefined;
|
||||
_id("citation-preview-loading").hidden = true;
|
||||
_id("citation-preview-content").hidden = errored;
|
||||
_id("citation-preview-error").hidden = !errored;
|
||||
_id("citation-preview-content").innerHTML = errored ? "" : html;
|
||||
|
|
|
|||
|
|
@ -112,6 +112,7 @@
|
|||
<div id="citation-preview-wrapper" class="vbox">
|
||||
<div id="citation-preview-content"></div>
|
||||
<div id="citation-preview-error" data-l10n-id="integration-citationDialog-preview-error" hidden="true"></div>
|
||||
<div id="citation-preview-loading" data-l10n-id="integration-citationDialog-preview-loading" hidden="true"></div>
|
||||
</div>
|
||||
<div class="divider subtle"></div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ integration-citationDialog-lib-message-annotations = { $search ->
|
|||
}
|
||||
integration-citationDialog-settings-keepSorted = Keep sources sorted
|
||||
integration-citationDialog-preview-error = Preview unavailable
|
||||
integration-citationDialog-preview-loading = Loading preview…
|
||||
integration-citationDialog-btn-displayPreview =
|
||||
.title = Display citation preview
|
||||
integration-citationDialog-btn-settings =
|
||||
|
|
|
|||
|
|
@ -587,7 +587,7 @@
|
|||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
#citation-preview-error {
|
||||
#citation-preview-error, #citation-preview-loading {
|
||||
padding-top: 2px;
|
||||
color: var(--fill-secondary);
|
||||
font-family: $font-family-base;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue