From: Aleksander Ɓukasz Date: Wed, 4 Jun 2014 12:03:31 +0000 (+0200) Subject: editor: canvas fix - fix selecting node without direct text node child X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/c6526aebeee1d516b8bd7c793fecda2fcb80bbdf?ds=inline editor: canvas fix - fix selecting node without direct text node child Without this fix, clicking element without direct text child element but with children containing text nodes resulted in selecting this child text element (while visual indication for the user was that the requested element was selected). --- diff --git a/src/editor/modules/documentCanvas/canvas/canvas.js b/src/editor/modules/documentCanvas/canvas/canvas.js index 05c109c..b234dd8 100644 --- a/src/editor/modules/documentCanvas/canvas/canvas.js +++ b/src/editor/modules/documentCanvas/canvas/canvas.js @@ -349,7 +349,7 @@ $.extend(Canvas.prototype, Backbone.Events, { if(byBrowser && byBrowser.parent().sameNode(nodeToLand)) { return byBrowser; } - return e.getVerticallyFirstTextElement(); + return e.getVerticallyFirstTextElement({considerChildren: false}); }.bind(this); var _markAsCurrent = function(element) { if(element instanceof documentElement.DocumentTextElement) { diff --git a/src/editor/modules/documentCanvas/canvas/genericElement.js b/src/editor/modules/documentCanvas/canvas/genericElement.js index 878e140..4dfbe59 100644 --- a/src/editor/modules/documentCanvas/canvas/genericElement.js +++ b/src/editor/modules/documentCanvas/canvas/genericElement.js @@ -80,13 +80,18 @@ $.extend(generic, { return toret; }, - getVerticallyFirstTextElement: function() { + getVerticallyFirstTextElement: function(params) { var toret; + + params = _.extend({ + considerChildren: true + }, params); + this.children().some(function(child) { if(child instanceof documentElement.DocumentTextElement) { toret = child; return true; // break - } else { + } else if(params.considerChildren) { toret = child.getVerticallyFirstTextElement(); if(toret) { return true; // break