Skip to content

Commit

Permalink
fix(file-list): drag and drop working
Browse files Browse the repository at this point in the history
  • Loading branch information
flauc committed Jan 20, 2025
1 parent 07a55bd commit 023008d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/lib/src/form-fields/file-list/file-list.wc.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@
export let displayFormatFunction;
let displayedFileNameString = '';
let grabbedEl: { style: string } | null = null;
let grabbedEl: HTMLElement | null = null;
let grabbedIndex = -1;
let startingY: number;
let startingX: number;
let internalFiles: any[] = [];
let browseFilesEl: HTMLInputElement;
let browseFilesEl: HTMLInputElement | null = null;
let loading = false;
let hoveringFile = false;
let fileElements: HTMLDivElement[] = [];
Expand Down Expand Up @@ -124,7 +124,7 @@
internalFiles = internalFiles.filter((i, ind) => index !== ind);
}
function handleFileInput(e) {
function handleFileInput(e: any) {
if (e.target.files.length) {
internalFiles = internalFiles.concat(filesToObjs(Array.from(e.target.files)));
dispatch('change', { unsaved: internalFiles.filter((el) => !el.saved).length });
Expand Down Expand Up @@ -163,7 +163,7 @@
el.name,
displayFormat,
displayFormatFunction
);
)!;
let obj: any = {
name: el.name,
size: returnFileSize(el.size),
Expand Down Expand Up @@ -240,7 +240,7 @@
function mouseup(e: any) {
if (grabbedEl) {
e.preventDefault();
const fileEl = e.target.closest('.file');
const fileEl = e.target.closest('.jp-file-list-file');
if (fileEl) {
const i = [...fileEl.parentNode.children].indexOf(fileEl);
const tmp = internalFiles[i];
Expand Down Expand Up @@ -283,6 +283,7 @@
userInvalidElement = false;
}
}
</script>

<svelte:document on:mousemove={mousemove} on:mouseup={mouseup} />
Expand Down

0 comments on commit 023008d

Please sign in to comment.