Skip to content

Commit 1ba9706

Browse files
author
Hesam Bahrami
authored
fix: multi-instance page placeholder list bug (#24)
1 parent 382c07a commit 1ba9706

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ class NestedSort {
180180
this.removeClassFromEl(this.targetedNode, this.classNames.targeted)
181181
this.cleanupPlaceholderLists();
182182
this.draggedNode = null
183+
this.targetedNode = null
183184
}
184185

185186
onDrop(e) {

test/main.test.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,28 @@ describe('NestedSort', () => {
377377

378378
expect(ns.draggedNode).toBeNull()
379379
})
380+
381+
it('should set the targetedNode property to null', () => {
382+
const ns = new NestedSort({
383+
data: [
384+
{ id: 1, text: 'One' },
385+
{ id: 2, text: 'Two' },
386+
],
387+
el: `#${dynamicListWrapperId}`,
388+
})
389+
390+
ns.draggedNode = document.querySelector('[data-id="1"]')
391+
ns.targetedNode = document.querySelector('[data-id="2"]')
392+
const stopPropagation = jest.fn()
393+
394+
ns.draggedNode.dispatchEvent(
395+
createEvent('dragend', {
396+
stopPropagation,
397+
})
398+
)
399+
400+
expect(ns.targetedNode).toBeNull()
401+
})
380402
})
381403

382404
describe('drop event', () => {

0 commit comments

Comments
 (0)