fix sortable bug with first loaded files

This commit is contained in:
vcoppe
2024-04-20 18:55:40 +02:00
parent 7885bdbce5
commit 1aa348266e

View File

@@ -42,12 +42,19 @@
selectedClass: 'sortable-selected', selectedClass: 'sortable-selected',
avoidImplicitDeselect: true, avoidImplicitDeselect: true,
onSelect: (e) => { onSelect: (e) => {
console.log('onSelect', e);
const index = parseInt(e.item.getAttribute('data-id')); const index = parseInt(e.item.getAttribute('data-id'));
addSelectFile($files[index]); addSelectFile($files[index]);
if (!e.originalEvent.shiftKey && $selectedFiles.size > 1) {
$selectedFiles.forEach((file) => {
if (file !== $files[index]) {
deselectFile(file);
const index = $files.indexOf(file);
Sortable.utils.deselect(buttons[index]);
}
});
}
}, },
onDeselect: (e) => { onDeselect: (e) => {
console.log('onDeselect');
const index = parseInt(e.item.getAttribute('data-id')); const index = parseInt(e.item.getAttribute('data-id'));
deselectFile($files[index]); deselectFile($files[index]);
} }
@@ -57,7 +64,6 @@
selectFiles.update(() => { selectFiles.update(() => {
return { return {
select: (file: GPXFile) => { select: (file: GPXFile) => {
console.log('select');
buttons.forEach((button) => { buttons.forEach((button) => {
if (button) { if (button) {
Sortable.utils.deselect(button); Sortable.utils.deselect(button);
@@ -68,13 +74,11 @@
selectFile(file); selectFile(file);
}, },
addSelect: (file: GPXFile) => { addSelect: (file: GPXFile) => {
console.log('addSelect');
const index = $files.indexOf(file); const index = $files.indexOf(file);
Sortable.utils.select(buttons[index]); Sortable.utils.select(buttons[index]);
addSelectFile(file); addSelectFile(file);
}, },
removeSelect: (file: GPXFile) => { removeSelect: (file: GPXFile) => {
console.log('removeSelect');
const index = $files.indexOf(file); const index = $files.indexOf(file);
Sortable.utils.deselect(buttons[index]); Sortable.utils.deselect(buttons[index]);
deselectFile(file); deselectFile(file);