From 098be27375d85f5cf99bfb9d3602b3ee76ffbbd3 Mon Sep 17 00:00:00 2001 From: Bogdan Abaev Date: Wed, 20 Aug 2025 10:23:44 -0700 Subject: [PATCH] citation dlg: fix row cutoff on linux after resize When resizing the window in list mode to match the height of the content, account for the difference between outerHeight and innerHeight of the window on Linux. outerHeight > innerHeight (perhaps Linux includes chrome, borders, etc. in its outerHeight), so we have to add their difference to the desired height for resizing. Otherwise, the visible dialog ends up receiving only some of the desired height and the last row is cut off. Also, ensure that in tests, we wait for searching triggered by switching dialog mode to finish before running the next search. Fixes: zotero#5502 --- chrome/content/zotero/integration/citationDialog.js | 7 +++++++ test/tests/citationDialogTest.js | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/chrome/content/zotero/integration/citationDialog.js b/chrome/content/zotero/integration/citationDialog.js index 7f6c09d9bd..c1755d4f7f 100644 --- a/chrome/content/zotero/integration/citationDialog.js +++ b/chrome/content/zotero/integration/citationDialog.js @@ -878,6 +878,13 @@ class ListLayout extends Layout { // set min height and resize the window let autoHeight = bubbleInputHeight + sectionsHeight + sectionsWrapperPadding + bottomHeight + marginOfError; + // window.resizeTo(X,Y) resizes the window so that it's outerHeight == Y. On mac and windows, + // innerHeight and outerHeight are the same. On linux, the outerHeight > innerHeight, perhaps + // outerHeight there includes chrome, borders, etc. This difference is accounted for below, so that the dialog + // itself (not the outer window) ends up with the desired height. + if (Zotero.isLinux) { + autoHeight += (window.outerHeight - window.innerHeight); + } let minHeight = bubbleInputHeight + bottomHeight; doc.documentElement.style.minHeight = `${minHeight}px`; diff --git a/test/tests/citationDialogTest.js b/test/tests/citationDialogTest.js index 110c6d7046..8dae8c2dca 100644 --- a/test/tests/citationDialogTest.js +++ b/test/tests/citationDialogTest.js @@ -415,6 +415,10 @@ describe("Citation Dialog", function () { it("should perform search in list mode", async function () { IOManager.toggleDialogMode("list"); + // Wait for search triggered after switching dialog modes to finish + while (SearchHandler.searching) { + await Zotero.Promise.delay(10); + } // Search for "one" await dialog.currentLayout.search("one", { skipDebounce: true }); // Selected items should have both "one_selected" and "one_selected_open" @@ -442,6 +446,10 @@ describe("Citation Dialog", function () { it("should perform search in library mode", async function () { IOManager.toggleDialogMode("library"); + // Wait for search triggered after switching dialog modes to finish + while (SearchHandler.searching) { + await Zotero.Promise.delay(10); + } // Search for "one" await dialog.currentLayout.search("one", { skipDebounce: true }); // Selected items should have both "one_selected" and "one_selected_open"