Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix drag-and-drop when dragging outside components #3177

Merged
merged 5 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,8 @@ export default function RenderOverlay({ bridge }: RenderOverlayProps) {
parentAwareBaseRect = {
x: isPageChild ? 0 : baseRect.x,
y: hasPositionGap ? baseRect.y : baseRect.y - parentGap,
width: isPageChild && parentRect ? parentRect.width : baseRect.width,
width:
isPageChild && parentRect ? parentRect.x * 2 + parentRect.width : baseRect.width,
height: baseRect.height + gapCount * parentGap,
};
}
Expand Down
35 changes: 35 additions & 0 deletions test/visual/components/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ test('showing drag-and-drop previews', async ({ page, argosScreenshot }) => {
boundingBox.y + (2 / 3) * boundingBox.height,
];

// Check all direction previews when dragging over component

const inputBoundingBox = await editorModel.appCanvas.locator('input').boundingBox();

await editorModel.dragNewComponentToCanvas(
Expand All @@ -126,6 +128,37 @@ test('showing drag-and-drop previews', async ({ page, argosScreenshot }) => {
});
await argosScreenshot('drop-preview-bottom', screenshotConfig);

// Check top, left and right previews when dragging outside component

await page.mouse.move(
inputBoundingBox!.x + inputBoundingBox!.width / 2,
inputBoundingBox!.y - 12,
{
steps: 10,
},
);
await argosScreenshot('drop-preview-outside-top', screenshotConfig);

await page.mouse.move(
inputBoundingBox!.x - 12,
inputBoundingBox!.y + inputBoundingBox!.height / 2,
{
steps: 1,
},
);
await argosScreenshot('drop-preview-outside-left', screenshotConfig);

await page.mouse.move(
inputBoundingBox!.x + inputBoundingBox!.width + 12,
inputBoundingBox!.y + inputBoundingBox!.height / 2,
{
steps: 1,
},
);
await argosScreenshot('drop-preview-outside-right', screenshotConfig);

// Check preview when dragging inside empty container

const containerDropAreaBoundingBox = await editorModel.appCanvas
.getByText('Drop component here')
.boundingBox();
Expand All @@ -139,6 +172,8 @@ test('showing drag-and-drop previews', async ({ page, argosScreenshot }) => {
);
await argosScreenshot('container-drop-preview-empty', screenshotConfig);

// Check all direction previews when dragging over component inside container

const containerButtonBoundingBox = await editorModel.appCanvas
.getByText('contained')
.boundingBox();
Expand Down
Loading