From 2d558b0a8488fdad783c32cb7c5000758394005b Mon Sep 17 00:00:00 2001 From: Balint Gabor <127662+gbalint@users.noreply.github.com> Date: Tue, 1 Oct 2024 17:59:00 +0200 Subject: [PATCH] Draw-to-insert to grid cell should not be absolute (#6442) **Problem:** Draw to insert into a grid cell should just define the size of the inserted element, but not the position. **Fix:** Made draw-to-insert similar to click-to-insert **Manual Tests:** I hereby swear that: - [x] I opened a hydrogen project and it loaded - [x] I could navigate to various routes in Preview mode --- .../draw-to-insert-strategy.spec.browser2.tsx | 12 ++++++------ .../grid-draw-to-insert-strategy.tsx | 18 ++---------------- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/editor/src/components/canvas/canvas-strategies/strategies/draw-to-insert-strategy.spec.browser2.tsx b/editor/src/components/canvas/canvas-strategies/strategies/draw-to-insert-strategy.spec.browser2.tsx index af5ab649508d..9c26194be566 100644 --- a/editor/src/components/canvas/canvas-strategies/strategies/draw-to-insert-strategy.spec.browser2.tsx +++ b/editor/src/components/canvas/canvas-strategies/strategies/draw-to-insert-strategy.spec.browser2.tsx @@ -324,9 +324,9 @@ export var storyboard = ( gridColumn: '2', gridRow: '1', height: '60px', - left: '84px', - position: 'absolute', - top: '151px', + left: '', + position: '', + top: '', width: '40px', }) }) @@ -371,9 +371,9 @@ export var storyboard = ( gridColumn: '1', gridRow: '1', height: '30px', - left: '126px', - position: 'absolute', - top: '76px', + left: '', + position: '', + top: '', width: '20px', }) }) diff --git a/editor/src/components/canvas/canvas-strategies/strategies/grid-draw-to-insert-strategy.tsx b/editor/src/components/canvas/canvas-strategies/strategies/grid-draw-to-insert-strategy.tsx index 7036621bc9c1..50965cc71a8e 100644 --- a/editor/src/components/canvas/canvas-strategies/strategies/grid-draw-to-insert-strategy.tsx +++ b/editor/src/components/canvas/canvas-strategies/strategies/grid-draw-to-insert-strategy.tsx @@ -47,6 +47,7 @@ import { setGridPropsCommands } from './grid-helpers' import { newReparentSubjects } from './reparent-helpers/reparent-strategy-helpers' import { getReparentTargetUnified } from './reparent-helpers/reparent-strategy-parent-lookup' import { getGridCellUnderMouseFromMetadata } from './grid-cell-bounds' +import { nukeAllAbsolutePositioningPropsCommands } from '../../../inspector/inspector-common' export const gridDrawToInsertText: CanvasStrategyFactory = ( canvasState: InteractionCanvasState, @@ -211,25 +212,10 @@ const gridDrawToInsertStrategyInner = ? [] : getWrappingCommands(insertedElementPath, maybeWrapperWithUid) - const isClick = interactionData.type === 'DRAG' && interactionData.drag == null - - // for click-to-insert, don't use absolute positioning - const clickToInsertCommands = isClick - ? [ - deleteProperties('always', insertedElementPath, [ - PP.create('style', 'position'), - PP.create('style', 'top'), - PP.create('style', 'left'), - PP.create('style', 'bottom'), - PP.create('style', 'right'), - ]), - ] - : [] - return strategyApplicationResult( [ insertionCommand, - ...clickToInsertCommands, + ...nukeAllAbsolutePositioningPropsCommands(insertedElementPath), // do not use absolute positioning in grid cells ...setGridPropsCommands(insertedElementPath, gridTemplate, { gridRowStart: { numericalPosition: gridCellCoordinates.row }, gridColumnStart: { numericalPosition: gridCellCoordinates.column },