Skip to content

Commit

Permalink
Draw-to-insert to grid cell should not be absolute (#6442)
Browse files Browse the repository at this point in the history
**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
  • Loading branch information
gbalint authored Oct 1, 2024
1 parent 41537c1 commit 2d558b0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,9 @@ export var storyboard = (
gridColumn: '2',
gridRow: '1',
height: '60px',
left: '84px',
position: 'absolute',
top: '151px',
left: '',
position: '',
top: '',
width: '40px',
})
})
Expand Down Expand Up @@ -371,9 +371,9 @@ export var storyboard = (
gridColumn: '1',
gridRow: '1',
height: '30px',
left: '126px',
position: 'absolute',
top: '76px',
left: '',
position: '',
top: '',
width: '20px',
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 },
Expand Down

0 comments on commit 2d558b0

Please sign in to comment.