-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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-1191: Fix drawing tools scenarios with ctrl pressed #6056
base: develop
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for label-studio-docs-new-theme canceled.
|
✅ Deploy Preview for heartex-docs canceled.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great 🔥
const isCtrlPressed = e.evt && (e.evt.metaKey || e.evt.ctrlKey); | ||
const hasSelection = self.control.annotation.hasSelection; | ||
|
||
return isCtrlPressed && !hasSelection; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may be misunderstanding something but based on the description if there is no selection we create a new region overtop existing regions. (this seems to allow it as coded)
but if there is a selection then we add to the selection - would that not go through here and fail? or does that go through another spot?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
based on the description if there is no selection we create a new region overtop existing regions
if there is a selection then we add to the selection
Only when the meta key is pressed, otherwise its the default behaviour as before which depends on the state as to the operation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are going to skip the interaction, the event will be processed inside the tool and it will draw region
label-studio/web/libs/editor/src/components/ImageView/ImageView.jsx
Lines 595 to 617 in 03837fc
if ( | |
// create regions over another regions with Cmd/Ctrl pressed | |
item.getSkipInteractions() || | |
e.target === item.stageRef || | |
findClosestParent(e.target, isRightElementToCatchToolInteractions) | |
) { | |
window.addEventListener("mousemove", this.handleGlobalMouseMove); | |
window.addEventListener("mouseup", this.handleGlobalMouseUp); | |
const { offsetX: x, offsetY: y } = e.evt; | |
// store the canvas coords for calculations in further events | |
const { left, top } = item.containerRef.getBoundingClientRect(); | |
this.canvasX = left; | |
this.canvasY = top; | |
if (this.skipNextMouseDown) { | |
this.skipNextMouseDown = false; | |
return true; | |
} | |
item.event("mousedown", e, x, y); | |
return true; | |
} | |
}; |
With the currently selected region, we will skip this interaction, but clicking on the region will still be processed.
label-studio/web/libs/editor/src/regions/RectRegion.jsx
Lines 514 to 522 in 03837fc
onClick={(e) => { | |
if (item.parent.getSkipInteractions()) return; | |
if (store.annotationStore.selected.relationMode) { | |
stage.container().style.cursor = Constants.DEFAULT_CURSOR; | |
} | |
item.setHighlight(false); | |
item.onClickRegion(e); | |
}} |
And it affects selection
label-studio/web/libs/editor/src/mixins/KonvaRegion.js
Lines 128 to 135 in 03837fc
const selectAction = () => { | |
const allowedDrawingThroughRegion = self.object.allowedDrawingThroughRegion; | |
// Prevent selecting interactions with an existing region | |
// If we have intention to draw a new region instead | |
if (additiveMode && allowedDrawingThroughRegion) return; | |
self._selectArea(additiveMode); | |
deferredSelectId = null; | |
}; |
So with ctrl/cmd key pressed and drawing tool selected it might draw over existed region if there is no selection and add/remove to/from selection if there is already selected regions.
I hope that I've mentioned here all meaningful spots,
'cause it's really a bit complicated. 😅
/selenium test
|
/git merge develop
|
/git merge develop
|
This fix changes behaviour into:
PR fulfills these requirements
[fix|feat|ci|chore|doc]: TICKET-ID: Short description of change made
ex.fix: DEV-XXXX: Removed inconsistent code usage causing intermittent errors
Change has impacts in these area(s)
Describe the reason for change
There is an intersection of two expected behaviours:
So that, with keeping ctrl/cmd pressed and clicking on the region we got:
But all that in the same time.
What feature flags were used to cover this change?
N/A
Does this PR introduce a breaking change?
What level of testing was included in the change?
Which logical domain(s) does this change affect?
Image
,Drawing tools