fix: Move and remove should match item by id

- Button does not respond to move and remove due to compare object instead of the id of the object
This commit is contained in:
Sheng Xiao
2020-06-06 13:11:05 -07:00
parent 35f5589f95
commit 0293ab6d5b
2 changed files with 18 additions and 17 deletions

View File

@ -3,7 +3,7 @@ import html2canvas from 'html2canvas';
import * as jsPDF from 'jspdf';
const move = (array, element, delta) => {
const index = array.indexOf(element);
const index = array.findIndex(item => item.id === element.id);
const newIndex = index + delta;
if (newIndex < 0 || newIndex === array.length) return;
const indexes = [index, newIndex].sort((a, b) => a - b);