citation dlg: first run guidance on 1st added item

Display the first run guidance panel when the first
item is added to the citation vs on initial open.
This commit is contained in:
Bogdan Abaev 2026-05-14 15:42:26 -07:00
parent 714d4416f8
commit 44aedf8652
3 changed files with 22 additions and 16 deletions

View file

@ -144,18 +144,6 @@ async function onLoad() {
}
});
//
// Show guidance panel on the first run. Noop on subsequent runs.
//
// Use localized locator string (e.g., "p10")
let locatorString = Zotero.Cite.getLocatorString("page", "short").toLowerCase()
// Strip trailing period ("p." → "p")
.replace(/\.$/, '')
+ "10";
doc.querySelector("guidance-panel").show({ l10nArgs: { locator: locatorString } });
// Hide guidance panel on any keypress
doc.addEventListener("keydown", () => doc.querySelector("guidance-panel").hide(), { capture: true, once: true });
DIALOG_STATE.loaded = true;
let initTime = timer.stop();
Zotero.debug(`Citation Dialog: initialized in ${initTime} s`);
@ -1395,6 +1383,15 @@ const IOManager = {
}
this.updateBubbleInput();
// Show guidance panel on the first run
if (DIALOG_STATE.isCitingItems() && !Zotero.Prefs.get("firstRunGuidanceShown.citationDialog")) {
doc.querySelector(".bubble").id = "first-bubble";
// Center the panel on the first bubble
let width = doc.querySelector(".bubble").getBoundingClientRect().width;
doc.querySelector("guidance-panel").setAttribute("x", Math.round(width / 2));
IOManager.showFirstRunDialog();
}
// Always refresh items list to make sure the opened and selected items are up to date
await currentLayout.refreshItemsList();
if (!noInputRefocus) {
@ -1581,6 +1578,17 @@ const IOManager = {
}
return desiredMode;
},
showFirstRunDialog() {
let locatorString = Zotero.Cite.getLocatorString("page", "short").toLowerCase()
// Strip trailing period ("p." → "p")
.replace(/\.$/, '')
+ "10";
// Use localized locator string (e.g., "p10")
doc.querySelector("guidance-panel").show({ l10nArgs: { locator: locatorString } });
// Hide guidance panel on any keypress
doc.addEventListener("keydown", () => doc.querySelector("guidance-panel").hide(), { capture: true, once: true });
},
// handle drag start of item nodes into bubble-input
_handleItemDragStart(event) {

View file

@ -183,7 +183,7 @@
</div>
</div>
</xul:panel>
<xul:guidance-panel about="citationDialog" for="z-icon-container" x="5"/>
<xul:guidance-panel about="citationDialog" for="first-bubble"/>
</div>
</body>
</html>

View file

@ -133,9 +133,7 @@ integration-warning-discard-changes = Discard Changes
integration-warning-command-is-running = A word processor integration command is already running.
first-run-guidance-citationDialog = Type a title, author, and/or year to search for a reference.
After you’ve made your selection, click the bubble or select it via the keyboard and press ↓/Space to show citation options such as page number, prefix, and suffix.
first-run-guidance-citationDialog = Click the bubble or select it via the ← key and press ↓/Space to customize citation options such as page number, prefix, and suffix.
You can also add a page number or other locator by including it with your search terms (e.g., “history { $locator }”) or by typing it after the bubble and pressing { return-or-enter }.