Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Fixed gallery image changing order randomly when dropped on itself (#…
Browse files Browse the repository at this point in the history
…1081)

no issue
- clear the cached `insertIndex` when hiding the drop position indicator
- update the gallery card's `_isDropAllowed` function to return `false` if the `droppabeIndex` (`insertIndex`) doesn't exist
  • Loading branch information
kevinansfield committed Dec 11, 2018
1 parent 6ba1c11 commit 7d0266e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/koenig-editor/addon/components/koenig-card-gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,8 @@ export default Component.extend({
// we don't allow an image to be dropped where it would end up in the
// same position within the gallery
_isDropAllowed(draggableIndex, droppableIndex, position = '') {
// can't drop on itself
if (draggableIndex === droppableIndex) {
// can't drop on itself or when droppableIndex doesn't exist
if (draggableIndex === droppableIndex || typeof droppableIndex === 'undefined') {
return false;
}

Expand Down
3 changes: 3 additions & 0 deletions lib/koenig-editor/addon/services/koenig-drag-drop-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,9 @@ export default Service.extend({
// make sure the indicator isn't shown due to a running timeout
run.cancel(this._dropIndicatorTimeout);

// clear droppable insert index
delete this.draggableInfo.insertIndex;

// reset all transforms
this._transformedDroppables.forEach((elem) => {
elem.style.transform = '';
Expand Down

0 comments on commit 7d0266e

Please sign in to comment.