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: LEAP-240: Prevent creating region on clicking outside selected one #5303

Merged
merged 12 commits into from
Jan 29, 2024
Merged
2 changes: 1 addition & 1 deletion label_studio/frontend/dist/lsf/js/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion label_studio/frontend/dist/lsf/js/main.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions label_studio/frontend/dist/lsf/version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"message": "fix: LEAP-246: Replace overlaping MIG hotkeys",
"commit": "309d0f9451619e3c714044ddc1ff99d91613fb6f",
"branch": "master",
"date": "2024-01-17T16:09:13Z"
"message": "fix: LEAP-240: Prevent creating region on clicking outside selected one",
"commit": "4faed9ac55d7386cbd9af8a1ade66d064a13d16e",
"branch": "fb-leap-240/fix-click-outside",
"date": "2024-01-18T04:45:00Z"
}
2 changes: 1 addition & 1 deletion web/dist/apps/labelstudio/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/dist/libs/editor/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/dist/libs/editor/main.js.map

Large diffs are not rendered by default.

31 changes: 25 additions & 6 deletions web/libs/editor/src/components/ImageView/ImageView.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,9 @@ export default observer(
crosshairRef = createRef();
handleDeferredMouseDown = null;
deferredClickTimeout = [];
skipMouseUp = false;
skipNextMouseDown = false;
skipNextClick = false;
skipNextMouseUp = false;
mouseDownPoint = null;

constructor(props) {
Expand All @@ -522,8 +524,8 @@ export default observer(
if (isFF(FF_DEV_1442)) {
this.handleDeferredMouseDown?.();
}
if (this.skipMouseUp) {
this.skipMouseUp = false;
if (this.skipNextClick) {
this.skipNextClick = false;
return;
}

Expand Down Expand Up @@ -575,6 +577,7 @@ export default observer(
const isPanTool = item.getToolsManager().findSelectedTool()?.fullName === 'ZoomPanTool';
const isMoveTool = item.getToolsManager().findSelectedTool()?.fullName === 'MoveTool';

this.skipNextMouseDown = this.skipNextMouseUp = this.skipNextClick = false;
if (isFF(FF_LSDV_4930)) {
this.mouseDownPoint = { x: e.evt.offsetX, y: e.evt.offsetY };
}
Expand Down Expand Up @@ -626,6 +629,10 @@ export default observer(

this.canvasX = left;
this.canvasY = top;
if (this.skipNextMouseDown) {
this.skipNextMouseDown = false;
return true;
}
item.event('mousedown', e, x, y);

return true;
Expand All @@ -652,7 +659,9 @@ export default observer(

const handleDeselection = () => {
item.annotation.unselectAll();
this.skipMouseUp = true;
this.skipNextMouseDown = true;
this.skipNextMouseUp = true;
this.skipNextClick = true;
};

this.handleDeferredClick(handleMouseDown, handleDeselection, eligibleToDeselect);
Expand Down Expand Up @@ -680,7 +689,7 @@ export default observer(

item.freezeHistory();

return item.event('mouseup', e, x - this.canvasX, y - this.canvasY);
return this.triggerMouseUp(e, x - this.canvasX, y - this.canvasY);
};

handleGlobalMouseMove = e => {
Expand All @@ -705,7 +714,17 @@ export default observer(
item.freezeHistory();
item.setSkipInteractions(false);

return item.event('mouseup', e, e.evt.offsetX, e.evt.offsetY);
return this.triggerMouseUp(e, e.evt.offsetX, e.evt.offsetY);
};

triggerMouseUp = (e, x, y) => {
if (this.skipNextMouseUp) {
this.skipNextMouseUp = false;
return;
}
const { item } = this.props;

return item.event('mouseup', e, x, y);
};

handleMouseMove = e => {
Expand Down
Loading