Commit e33c2cd8 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Fix leaving annotations on designs not fitting the viewport

parent c16e2ad6
...@@ -46,6 +46,7 @@ export default { ...@@ -46,6 +46,7 @@ export default {
height: 0, height: 0,
}, },
initialLoad: true, initialLoad: true,
startDragPosition: null,
lastDragPosition: null, lastDragPosition: null,
}; };
}, },
...@@ -218,10 +219,12 @@ export default { ...@@ -218,10 +219,12 @@ export default {
onPresentationMousedown({ clientX, clientY }) { onPresentationMousedown({ clientX, clientY }) {
if (!this.isDesignOverflowing()) return; if (!this.isDesignOverflowing()) return;
this.lastDragPosition = { this.startDragPosition = {
x: clientX, x: clientX,
y: clientY, y: clientY,
}; };
this.lastDragPosition = { ...this.startDragPosition };
}, },
onPresentationMousemove({ clientX, clientY }) { onPresentationMousemove({ clientX, clientY }) {
if (!this.lastDragPosition) return; if (!this.lastDragPosition) return;
...@@ -239,7 +242,14 @@ export default { ...@@ -239,7 +242,14 @@ export default {
y: clientY, y: clientY,
}; };
}, },
onPresentationMouseup() { onPresentationMouseup({ offsetX, offsetY }) {
if (
this.startDragPosition?.x === this.lastDragPosition?.x &&
this.startDragPosition?.y === this.lastDragPosition?.y
) {
this.openCommentForm({ x: offsetX, y: offsetY });
}
this.lastDragPosition = null; this.lastDragPosition = null;
}, },
isDesignOverflowing() { isDesignOverflowing() {
......
---
title: Resolve Creating an annotation on the design that is bigger that screen size
is broken
merge_request: 29351
author:
type: fixed
...@@ -425,6 +425,39 @@ describe('Design management design presentation component', () => { ...@@ -425,6 +425,39 @@ describe('Design management design presentation component', () => {
}); });
}); });
describe('onPresentationMouseUp when design is overflowing', () => {
it('does not open a comment form if design was dragged', () => {
const startDragPosition = { x: 1, y: 1 };
const lastDragPosition = { x: 2, y: 2 };
createComponent({}, { startDragPosition, lastDragPosition });
wrapper.vm.onPresentationMouseup({ offsetX: 2, offsetY: 2 });
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted('openCommentForm')).toBeFalsy();
});
});
it('opens a comment form if design was not dragged', () => {
const startDragPosition = { x: 1, y: 1 };
const lastDragPosition = { x: 1, y: 1 };
createComponent(
{},
{
startDragPosition,
lastDragPosition,
...mockOverlayData,
},
);
wrapper.vm.onPresentationMouseup({ offsetX: 2, offsetY: 2 });
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.emitted('openCommentForm')).toBeDefined();
});
});
});
describe('when clicking and dragging', () => { describe('when clicking and dragging', () => {
it.each` it.each`
description | useTouchEvents description | useTouchEvents
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment