From 9bb65361cec5284e5b278735be32f99760fe3361 Mon Sep 17 00:00:00 2001 From: Federico Ruggi <1081051+ruggi@users.noreply.github.com> Date: Wed, 2 Oct 2024 12:49:34 +0200 Subject: [PATCH] Hide grid resize handles on both sides when too crowded (#6449) **Problem:** If even one side of a grid is too crowded for resize controls, hide the controls on the other side as well. **Fix:** 1. Move the check for crowdedness to cover both axii 2. Ensure that the crowdedness check works fine with very narrow cols/rows (shorter than the resize handle) but there is still room enough to display the handles https://github.com/user-attachments/assets/52e81327-b159-413a-b74c-34fd554a6e29 Fixes #6447 --- .../canvas/controls/grid-controls.tsx | 54 ++++++++++++++----- 1 file changed, 40 insertions(+), 14 deletions(-) diff --git a/editor/src/components/canvas/controls/grid-controls.tsx b/editor/src/components/canvas/controls/grid-controls.tsx index c651f64879d4..6c9958557dd7 100644 --- a/editor/src/components/canvas/controls/grid-controls.tsx +++ b/editor/src/components/canvas/controls/grid-controls.tsx @@ -405,12 +405,6 @@ export const GridResizing = React.memo((props: GridResizingProps) => { }) }, [props.fromPropsAxisValues, resizingIndex]) - const scale = useEditorState( - Substores.canvas, - (store) => store.editor.canvas.scale, - 'GridResizing scale', - ) - if (props.axisValues == null) { return null } @@ -419,11 +413,6 @@ export const GridResizing = React.memo((props: GridResizingProps) => { const size = GRID_RESIZE_HANDLE_CONTAINER_SIZE / canvasScale const dimensions = props.axisValues.dimensions - const hideControls = dimensions.some((dim) => { - const scaledSize = (dim.type === 'NUMBER' ? dim.value.value : 0) * scale - return scaledSize < GRID_RESIZE_HANDLE_SIZE - }) - return (