Skip to content

Commit

Permalink
fix: layout bug when collection search is open
Browse files Browse the repository at this point in the history
  • Loading branch information
windingwind committed Feb 24, 2024
1 parent 4452401 commit d5aa38c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"unist-util-visit": "^5.0.0",
"unist-util-visit-parents": "^6.0.1",
"yamljs": "^0.3.0",
"zotero-plugin-toolkit": "^2.3.15"
"zotero-plugin-toolkit": "^2.3.22"
},
"devDependencies": {
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
Expand Down
21 changes: 19 additions & 2 deletions src/modules/workspace/tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function registerWorkspaceTab(win: Window) {
if (!spacer) {
return;
}
ztoolkit.UI.insertElementBefore(
const tabButton = ztoolkit.UI.insertElementBefore(
{
tag: "toolbarbutton",
classList: ["zotero-tb-button"],
Expand All @@ -39,8 +39,25 @@ export function registerWorkspaceTab(win: Window) {
],
},
spacer,
) as XUL.ToolBarButton;
win.addEventListener("message", messageHandler, false);
const collectionSearch = doc.querySelector("#zotero-collections-search")!;
const ob = new (ztoolkit.getGlobal("MutationObserver"))((muts) => {
tabButton.hidden = !!collectionSearch?.classList.contains("visible");
});
ob.observe(collectionSearch, {
attributes: true,
attributeFilter: ["class"],
});

win.addEventListener(
"unload",
() => {
ob.disconnect();
win.removeEventListener("message", messageHandler);
},
{ once: true },
);
win.addEventListener("message", (e) => messageHandler(e), false);
}

export async function openWorkspaceTab() {
Expand Down

0 comments on commit d5aa38c

Please sign in to comment.