Skip to content

Commit

Permalink
fix: file-upload not forwarding file
Browse files Browse the repository at this point in the history
  • Loading branch information
flauc committed Dec 15, 2023
1 parent 605d419 commit d865e95
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions packages/lib/src/form-fields/file-upload.wc.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@
return value;
}
async function handleLocalChange(file) {
async function handleLocalChange(f) {
if (service && service.maxSize) {
if (file.size > service.maxSize) {
dispatch('rejected', { file: file.name, code: 'maxSize' });
if (f.size > service.maxSize) {
dispatch('rejected', { file: f.name, code: 'maxSize' });
return;
}
}
isLocal = true;
file = file;
value = file.name;
file = f;
value = f.name;
if (file['type'].split('/')[0] === 'image') {
const base64 = (await convertBase64(file)) as string;
img = base64;
Expand Down Expand Up @@ -104,15 +104,9 @@
let style: string = '';
if (availableSpaceBelow < dropdownHeight) {
style = `
bottom: ${window.innerHeight - rect.top}px;
right: ${rect.left}px;
`;
style = `bottom: ${window.innerHeight - rect.top}px;right: ${rect.left}px;`;
} else {
style = `
top: ${rect.bottom}px;
right: ${rect.left}px;
`;
style = `top:${rect.bottom}px;right: ${rect.left}px;`;
}
previewStyle = style;
Expand Down Expand Up @@ -148,15 +142,13 @@
<span class="field-label" class:move={inputFocused || value}>{@html label}</span>

<div class="field-icons">
<label for={`${name}`} class="field-icon field-icon-upload">
<label for={name} class="field-icon field-icon-upload">
<input
type="file"
id={`${name}`}
id={name}
class="field-upload"
accept={service && service.acceptedFiles}
on:change={(e) => {
filePicked(e);
}}
on:change={filePicked}
on:focus={() => (inputFocused = true)}
on:blur={() => (inputFocused = false)}
/>
Expand Down

0 comments on commit d865e95

Please sign in to comment.