Skip to content

Commit

Permalink
fixing a bug where dragging.style.display was not restored on dragend (
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomasz Krakowiak committed Jun 29, 2021
1 parent 0f860ff commit bbc209b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/html5sortable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,10 @@ export default function sortable (sortableElements, options: configuration|objec
if (dragging.getAttribute('aria-copied') === 'true' && data(dragging, 'dropped') !== 'true') {
dragging.remove()
}

if (dragging.oldDisplay !== undefined) {
dragging.style.display = dragging.oldDisplay
delete dragging.oldDisplay
}
const visiblePlaceholder = Array.from(stores.values()).map(data => data.placeholder)
.filter(placeholder => placeholder instanceof HTMLElement)
.filter(isInDom)[0]
Expand Down Expand Up @@ -475,8 +478,10 @@ export default function sortable (sortableElements, options: configuration|objec
if (visiblePlaceholder) {
visiblePlaceholder.replaceWith(dragging)
// to avoid flickering restoring element display immediately after replacing placeholder
dragging.style.display = dragging.oldDisplay
delete dragging.oldDisplay
if (dragging.oldDisplay !== undefined) {
dragging.style.display = dragging.oldDisplay
delete dragging.oldDisplay
}
} else {
// set the dropped value to 'false' to delete copied dragging at the time of 'dragend'
data(dragging, 'dropped', 'false')
Expand Down

0 comments on commit bbc209b

Please sign in to comment.