Skip to content

Commit

Permalink
Make sure grid cell parents have children and have a template (#6126)
Browse files Browse the repository at this point in the history
**Problem:**

An element can be detected as a grid cell even if it's not inside a grid
parent.

**Fix:**

Fix that.

Fixes #6125
  • Loading branch information
ruggi authored Jul 25, 2024
1 parent 1b14bf9 commit 7116c50
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion editor/src/core/model/element-metadata-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,15 @@ export const MetadataUtils = {
},
isGridCell(metadata: ElementInstanceMetadataMap, path: ElementPath): boolean {
const parent = MetadataUtils.findElementByElementPath(metadata, EP.parentPath(path))
return MetadataUtils.isGridLayoutedContainer(parent)
return (
parent != null &&
isRight(parent.element) &&
isJSXElement(parent.element.value) &&
parent.element.value.children.length > 0 &&
parent.specialSizeMeasurements.containerGridProperties.gridTemplateColumns != null &&
parent.specialSizeMeasurements.containerGridProperties.gridTemplateRows != null &&
MetadataUtils.isGridLayoutedContainer(parent)
)
},
isPositionAbsolute(instance: ElementInstanceMetadata | null): boolean {
return instance?.specialSizeMeasurements.position === 'absolute'
Expand Down

0 comments on commit 7116c50

Please sign in to comment.