diff --git a/editor/src/components/canvas/canvas-strategies/strategies/grid-element-change-location-strategy.spec.browser2.tsx b/editor/src/components/canvas/canvas-strategies/strategies/grid-element-change-location-strategy.spec.browser2.tsx index a0774e94e142..5dcfb2072f27 100644 --- a/editor/src/components/canvas/canvas-strategies/strategies/grid-element-change-location-strategy.spec.browser2.tsx +++ b/editor/src/components/canvas/canvas-strategies/strategies/grid-element-change-location-strategy.spec.browser2.tsx @@ -1,6 +1,6 @@ import * as EP from '../../../../core/shared/element-path' import { offsetPoint, windowPoint } from '../../../../core/shared/math-utils' -import { selectComponentsForTest } from '../../../../utils/utils.test-utils' +import { selectComponentsForTest, wait } from '../../../../utils/utils.test-utils' import CanvasActions from '../../canvas-actions' import { GridCellTestId } from '../../controls/grid-controls-for-strategies' import { mouseDownAtPoint, mouseMoveToPoint, mouseUpAtPoint } from '../../event-helpers.test-utils' @@ -28,6 +28,34 @@ describe('grid element change location strategy', () => { }) }) + it('does not alter the grid template', async () => { + const editor = await renderTestEditorWithCode( + ProjectCodeFractionalTemplate, + 'await-first-dom-report', + ) + + const testId = 'aaa' + const { gridRowStart, gridRowEnd, gridColumnStart, gridColumnEnd } = await runGridMoveTest( + editor, + { + scale: 1, + gridPath: 'sb/scene/grid', + testId: testId, + }, + ) + + expect({ gridRowStart, gridRowEnd, gridColumnStart, gridColumnEnd }).toEqual({ + gridColumnEnd: '7', + gridColumnStart: '3', + gridRowEnd: '4', + gridRowStart: '2', + }) + + const grid = await editor.renderedDOM.findByTestId('grid') + expect(grid.style.gridTemplateColumns).toEqual('1fr 1fr 2fr 2fr 1fr 1fr') + expect(grid.style.gridTemplateRows).toEqual('1fr 1fr 2fr 1fr') + }) + describe('component items', () => { it('can change the location of components on a grid when component takes style prop', async () => { const editor = await renderTestEditorWithCode( @@ -881,6 +909,87 @@ export var storyboard = ( ) ` +const ProjectCodeFractionalTemplate = `import * as React from 'react' +import { Scene, Storyboard, Placeholder } from 'utopia-api' + +export var storyboard = ( + + +
+
+
+ + +
+ + +) +` + const makeProjectCodeWithItemComponent = ( itemComponentCode: string, ) => `import * as React from 'react' diff --git a/editor/src/components/canvas/dom-walker.ts b/editor/src/components/canvas/dom-walker.ts index baeb2ca0da52..00a78950527b 100644 --- a/editor/src/components/canvas/dom-walker.ts +++ b/editor/src/components/canvas/dom-walker.ts @@ -930,7 +930,9 @@ function getSpecialMeasurements( : null const containerGridPropertiesFromProps = getGridContainerProperties(element.style) - const parentContainerGridPropertiesFromProps = getGridContainerProperties(parentElementStyle) + const parentContainerGridPropertiesFromProps = getGridContainerProperties( + element.parentElement?.style ?? parentElementStyle, + ) const containerGridProperties = getGridContainerProperties(computedStyle, { dynamicCols: isDynamicGridTemplate(containerGridPropertiesFromProps.gridTemplateColumns), dynamicRows: isDynamicGridTemplate(containerGridPropertiesFromProps.gridTemplateRows),