Merge branch '21128-toolbar-context-menu'
[arvados-workbench2.git] / src / views / workbench / workbench.tsx
index 385ffeff4074d02d5dcda604c926585cca2c9a79..bc2396f7cf8c2930444d6ecb3bb80324a9d5326d 100644 (file)
@@ -292,7 +292,7 @@ const applyCollapsedState = isCollapsed => {
     const totalWidth: number = document.getElementsByClassName("splitter-layout")[0]?.clientWidth;
     const rightPanelExpandedWidth = (totalWidth - COLLAPSE_ICON_SIZE) / (totalWidth / 100);
     if (rightPanel) {
-        rightPanel.setAttribute("style", `width: ${isCollapsed ? rightPanelExpandedWidth : getSplitterInitialSize()}%`);
+        rightPanel.setAttribute("style", `width: ${isCollapsed ? `calc(${rightPanelExpandedWidth}% - 1rem)` : `${getSplitterInitialSize()}%`}`);
     }
     const splitter = document.getElementsByClassName("layout-splitter")[0];
     isCollapsed ? splitter?.classList.add("layout-splitter-disabled") : splitter?.classList.remove("layout-splitter-disabled");
@@ -300,7 +300,7 @@ const applyCollapsedState = isCollapsed => {
 
 export const WorkbenchPanel = withStyles(styles)((props: WorkbenchPanelProps) => {
     //panel size will not scale automatically on window resize, so we do it manually
-    window.addEventListener("resize", () => applyCollapsedState(props.sidePanelIsCollapsed));
+    if (props && props.sidePanelIsCollapsed) window.addEventListener("resize", () => applyCollapsedState(props.sidePanelIsCollapsed));
     applyCollapsedState(props.sidePanelIsCollapsed);
 
     return (