diff --git a/angular-legacy-sortable.js b/angular-legacy-sortable.js index ba8f868..7b40199 100644 --- a/angular-legacy-sortable.js +++ b/angular-legacy-sortable.js @@ -155,6 +155,7 @@ watchers = null; sortable = null; nextSibling = null; + removed = null; } @@ -171,6 +172,7 @@ onEnd: function (/**Event*/evt) { _emitEvent(evt, removed); scope.$apply(); + removed = null; }, onAdd: function (/**Event*/evt) { _sync(evt); diff --git a/e2e/conf.js b/e2e/conf.js index f469e30..ec0f6c1 100644 --- a/e2e/conf.js +++ b/e2e/conf.js @@ -1,4 +1,4 @@ exports.config = { seleniumAddress: 'http://localhost:4444/wd/hub', - specs: ['./basic-drag-drop.e2e.js'], + specs: ['./basic-drag-drop.e2e.js', './nested-drag-drop.e2e.js'], } diff --git a/e2e/nested-drag-drop.e2e.js b/e2e/nested-drag-drop.e2e.js new file mode 100644 index 0000000..f599ed5 --- /dev/null +++ b/e2e/nested-drag-drop.e2e.js @@ -0,0 +1,21 @@ +describe('nested drag and drop', () => { + it('should have correct model after moving between lists', () => { + browser.get('http://localhost:8080/nested.html') + browser.executeScript('$("#item2").simulate("drag-n-drop", { dragTarget: $("#item3"), interpolation: {stepWidth: 2, stepDelay: 30}});') + browser.sleep(1000) + element(by.id('main-list')).evaluate('$ctrl.lastDragged.name').then(function(value){ + expect(value).toBe('item2'); + }) + browser.executeScript('$("#item3").simulate("drag-n-drop", { dragTarget: $("#subitem1"), interpolation: {stepWidth: 2, stepDelay: 30}});') + browser.sleep(1000) + element(by.id('main-list')).evaluate('$ctrl.lastDragged.name').then(function(value){ + expect(value).toBe('item3'); + }) + browser.executeScript('$("#item1").simulate("drag-n-drop", { dragTarget: $("#item2"), interpolation: {stepWidth: 2, stepDelay: 30}});') + browser.sleep(1000) + element(by.id('main-list')).evaluate('$ctrl.lastDragged.name').then(function(value){ + expect(value).toBe('item1'); + }) + }) +}) + \ No newline at end of file diff --git a/example/nested.html b/example/nested.html new file mode 100644 index 0000000..b7612fd --- /dev/null +++ b/example/nested.html @@ -0,0 +1,18 @@ + +
+ + + + + + + + + + + + + +