1
0
Fork 0
mirror of https://github.com/TryGhost/Ghost-Admin.git synced 2023-12-14 02:33:04 +01:00

Fixed drag-n-drop reorder of gallery images not responding to drops

no issue
- https://github.com/TryGhost/Ghost-Admin/pull/1081 introduced a bug where the `insertIndex` was being cleared every time we showed the drop position indicator because we hide the indicator as a reset every time we show the indicator. This meant every drop was missing the required insertIndex.
- added a flag to the `_hideDropIndicator` function so that a reset when showing the indicator doesn't clear the required information
This commit is contained in:
Kevin Ansfield 2018-12-11 13:20:05 +00:00
parent 23fa35c3c6
commit 5afdb552df

View file

@ -341,8 +341,8 @@ export default Service.extend({
_showDropIndicator({direction, position, beforeElems, afterElems}) {
let dropIndicator = this._dropIndicator;
// reset everything before re-displaying indicator
this._hideDropIndicator();
// reset everything except insertIndex before re-displaying indicator
this._hideDropIndicator({clearInsertIndex: false});
if (direction === 'horizontal') {
beforeElems.forEach((elem) => {
@ -405,12 +405,15 @@ export default Service.extend({
// TODO: handle vertical drag/drop
},
_hideDropIndicator() {
_hideDropIndicator({clearInsertIndex = true} = {}) {
// make sure the indicator isn't shown due to a running timeout
run.cancel(this._dropIndicatorTimeout);
// clear droppable insert index
delete this.draggableInfo.insertIndex;
// clear droppable insert index unless instructed not to (eg, when
// resetting the display before re-positioning the indicator)
if (clearInsertIndex) {
delete this.draggableInfo.insertIndex;
}
// reset all transforms
this._transformedDroppables.forEach((elem) => {