Skip to content

Commit

Permalink
#2060 — Don't break the selection if the user's cursor goes beyond th…
Browse files Browse the repository at this point in the history
…e canvas
  • Loading branch information
Stanislav Permiakov authored and Stanislav Permiakov committed Jan 10, 2023
1 parent cc5a0ec commit 24e78e2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
19 changes: 10 additions & 9 deletions packages/ketcher-react/src/script/editor/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,17 +616,18 @@ function updateLastCursorPosition(editor: Editor, event) {
function domEventSetup(editor: Editor, clientArea) {
// TODO: addEventListener('resize', ...);
;[
'click',
'dblclick',
'mousedown',
'mousemove',
'mouseup',
'mouseleave',
'mouseover'
].forEach((eventName) => {
{ target: clientArea, eventName: 'click' },
{ target: clientArea, eventName: 'dblclick' },
{ target: clientArea, eventName: 'mousedown' },
{ target: document, eventName: 'mousemove' },
{ target: document, eventName: 'mouseup' },
{ target: document, eventName: 'mouseleave' },
{ target: clientArea, eventName: 'mouseover' }
].forEach(({ target, eventName }) => {
editor.event[eventName] = new DOMSubscription()
const subs = editor.event[eventName]
clientArea.addEventListener(eventName, subs.dispatch.bind(subs))

target.addEventListener(eventName, subs.dispatch.bind(subs))

subs.add((event) => {
updateLastCursorPosition(editor, event)
Expand Down
6 changes: 5 additions & 1 deletion packages/ketcher-react/src/script/editor/tool/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,11 @@ class SelectTool {
// TODO it catches more events than needed, to be re-factored
this.selectElementsOnCanvas(newSelected, editor, event)
} else if (this.#lassoHelper.fragment) {
if (!event.shiftKey) editor.selection(null)
if (
!event.shiftKey &&
this.editor.render.clientArea.contains(event.target)
)
editor.selection(null)
}
editor.event.message.dispatch({
info: false
Expand Down

0 comments on commit 24e78e2

Please sign in to comment.