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 4 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
55 changes: 45 additions & 10 deletions test/visual/components/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ test('showing grid while resizing elements', async ({ page, argosScreenshot }) =
await page.mouse.move(
firstInputBoundingBox!.x + firstInputBoundingBox!.width - 5,
firstInputBoundingBox!.y + firstInputBoundingBox!.height / 2,
{ steps: 10 },
{ steps: 1 },
);

await page.mouse.down();

await page.mouse.move(
firstInputBoundingBox!.x + firstInputBoundingBox!.width / 2,
firstInputBoundingBox!.y + firstInputBoundingBox!.height / 2,
{ steps: 10 },
{ steps: 1 },
);

await argosScreenshot('resize-grid');
Expand Down 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 @@ -112,20 +114,51 @@ test('showing drag-and-drop previews', async ({ page, argosScreenshot }) => {
await argosScreenshot('drop-preview-left', screenshotConfig);

await page.mouse.move(...getDropPreviewTopCoordinates(inputBoundingBox!), {
steps: 10,
steps: 1,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10 steps was misleading, it wasn't really screenshotting the final state after the drag.

});
await argosScreenshot('drop-preview-top', screenshotConfig);

await page.mouse.move(...getDropPreviewRightCoordinates(inputBoundingBox!), {
steps: 10,
steps: 1,
});
await argosScreenshot('drop-preview-right', screenshotConfig);

await page.mouse.move(...getDropPreviewBottomCoordinates(inputBoundingBox!), {
steps: 10,
steps: 1,
});
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: 1,
},
);
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 @@ -134,32 +167,34 @@ test('showing drag-and-drop previews', async ({ page, argosScreenshot }) => {
containerDropAreaBoundingBox!.x + containerDropAreaBoundingBox!.width / 2,
containerDropAreaBoundingBox!.y + containerDropAreaBoundingBox!.height / 2,
{
steps: 10,
steps: 1,
},
);
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();

await page.mouse.move(...getDropPreviewLeftCoordinates(containerButtonBoundingBox!), {
steps: 10,
steps: 1,
});
await argosScreenshot('container-drop-preview-left', screenshotConfig);

await page.mouse.move(...getDropPreviewTopCoordinates(containerButtonBoundingBox!), {
steps: 10,
steps: 1,
});
await argosScreenshot('container-drop-preview-top', screenshotConfig);

await page.mouse.move(...getDropPreviewRightCoordinates(containerButtonBoundingBox!), {
steps: 10,
steps: 1,
});
await argosScreenshot('container-drop-preview-right', screenshotConfig);

await page.mouse.move(...getDropPreviewBottomCoordinates(containerButtonBoundingBox!), {
steps: 10,
steps: 1,
});
await argosScreenshot('container-drop-preview-bottom', screenshotConfig);
});
Loading