From: Aleksander Ɓukasz Date: Mon, 12 May 2014 08:51:54 +0000 (+0200) Subject: editor: canvas bug fix X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/36d06d92f91870d431dc4d203334def8fc891ee4?ds=sidebyside editor: canvas bug fix --- diff --git a/src/editor/modules/documentCanvas/canvas/canvas.test.js b/src/editor/modules/documentCanvas/canvas/canvas.test.js index f64754f..492292c 100644 --- a/src/editor/modules/documentCanvas/canvas/canvas.test.js +++ b/src/editor/modules/documentCanvas/canvas/canvas.test.js @@ -243,6 +243,19 @@ describe('Default document changes handling', function() { c.wlxmlDocument.root.contents()[0].setText('cat'); expect(c.doc().children()[0].getText()).to.equal('cat'); }); + + describe('Regression tests', function() { + it('handles moving node after its next neighbour correctly', function() { + var c = getCanvasFromXML('
'), + doc = c.wlxmlDocument, + a = doc.root.contents()[0], + b = doc.root.contents()[1]; + b.after(a); + var sectionChildren = c.doc().children(); + expect(sectionChildren[0].wlxmlNode.getTagName()).to.equal('b'); + expect(sectionChildren[1].wlxmlNode.getTagName()).to.equal('a'); + }); + }); }); describe('Custom elements based on wlxml class attribute', function() { diff --git a/src/editor/modules/documentCanvas/canvas/genericElement.js b/src/editor/modules/documentCanvas/canvas/genericElement.js index 4bdc524..a2601f8 100644 --- a/src/editor/modules/documentCanvas/canvas/genericElement.js +++ b/src/editor/modules/documentCanvas/canvas/genericElement.js @@ -105,6 +105,9 @@ $.extend(generic, { if(event.type === 'nodeMoved') { actionArg = utils.getElementForNode(event.meta.node, event.meta.parent); + if(actionArg.sameNode(referenceElement)) { + referenceElement = this.children()[nodeIndex]; + } } else { actionArg = event.meta.node; }