From 41bcc758201d42b62e7a6fdd9b85c8294e14d482 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Wed, 12 Mar 2014 17:00:30 +0100 Subject: [PATCH 1/1] editor: fix selecting text spanning multiple nodes in Chrome Chrome 33 started triggering click events for a nearest common parent when mousedown occurred on a different element than mouseup. This was causing selecting single canvas node element when making text selection across nodes and consequently removing that selection. --- src/editor/modules/documentCanvas/canvas/canvas.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/editor/modules/documentCanvas/canvas/canvas.js b/src/editor/modules/documentCanvas/canvas/canvas.js index 428cedc..d8d81b8 100644 --- a/src/editor/modules/documentCanvas/canvas/canvas.js +++ b/src/editor/modules/documentCanvas/canvas/canvas.js @@ -89,13 +89,20 @@ $.extend(Canvas.prototype, { keyboard.handleKey(e, this); }.bind(this)); + var mouseDown; + this.wrapper.on('mousedown', '[document-node-element], [document-text-element]', function(e) { + mouseDown = e.target; + }); + this.wrapper.on('click', '[document-node-element], [document-text-element]', function(e) { e.stopPropagation(); if(e.originalEvent.detail === 3) { e.preventDefault(); canvas._moveCaretToTextElement(canvas.getDocumentElement(e.currentTarget), 'whole'); } else { - canvas.setCurrentElement(canvas.getDocumentElement(e.currentTarget), {caretTo: false}); + if(mouseDown === e.target) { + canvas.setCurrentElement(canvas.getDocumentElement(e.currentTarget), {caretTo: false}); + } } }); -- 2.20.1