fix: layout bug when collection search is open
This commit is contained in:
parent
44524014d2
commit
d5aa38cb79
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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"],
|
||||
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue