Skip to content

Commit

Permalink
Merge pull request #796 from meiamsome/fix/reorder-layout-idx-fixes
Browse files Browse the repository at this point in the history
FIX: ReorderLayout should not rely on layout and content ids matching
  • Loading branch information
sphinxrave authored Dec 29, 2024
2 parents 6fdecbd + 5a8e13d commit fc9788e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/components/multiview/ReorderLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
class="layout-preview-cell"
:style="getStyle(l)"
@dragover="onDragOver"
@drop="onDrop($event, l.i)"
@drop="onDrop($event, idx)"
>
<div
v-if="content && content[l.i]"
Expand Down Expand Up @@ -135,9 +135,9 @@ export default {
const unitX = x / (width / 24);
const unitY = y / (height / 24);
// Find intersecting cell
const dropCell = this.layout.find((l) => unitX >= l.x && unitX < (l.x + l.w) && unitY >= l.y && unitY < (l.y + l.h));
if (dropCell) {
this.$store.commit("multiview/swapGridPosition", { id1: startIdx, id2: dropCell.i });
const dropCellIdx = this.layout.findIndex((l) => unitX >= l.x && unitX < (l.x + l.w) && unitY >= l.y && unitY < (l.y + l.h));
if (dropCellIdx !== undefined) {
this.$store.commit("multiview/swapGridPosition", { id1: startIdx, id2: dropCellIdx });
}
this.draggingIdx = -1;
},
Expand Down

0 comments on commit fc9788e

Please sign in to comment.