Skip to content

Commit

Permalink
Fix ruler layout calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
JonnyBurger committed Sep 3, 2024
1 parent bb80534 commit cb973af
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion packages/studio/src/components/TopPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,22 @@ export const TopPanel: React.FC<{
[rulersAreVisible],
);

const sizeWithRulersApplied = useMemo(() => {
if (!rulersAreVisible) {
return size;
}

if (!size) {
return null;
}

return {
...size,
width: size.width - RULER_WIDTH,
height: size.height - RULER_WIDTH,
};
}, [rulersAreVisible, size]);

const onCollapseLeft = useCallback(() => {
setSidebarCollapsedState({left: 'collapsed', right: null});
}, [setSidebarCollapsedState]);
Expand Down Expand Up @@ -142,7 +158,9 @@ export const TopPanel: React.FC<{
>
<SplitterElement sticky={null} type="flexer">
<div ref={drawRef} style={canvasContainerStyle}>
{size ? <CanvasOrLoading size={size} /> : null}
{sizeWithRulersApplied ? (
<CanvasOrLoading size={sizeWithRulersApplied} />
) : null}
</div>
</SplitterElement>
{actualStateRight === 'expanded' ? (
Expand Down

0 comments on commit cb973af

Please sign in to comment.