fix(file-uploader): FileUploader change detail should be File[] instead of FileList (#1117)

Fixes #1112
This commit is contained in:
metonym 2022-02-21 08:34:03 -08:00 committed by GitHub
commit 7602731b0b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 38 additions and 18 deletions

View file

@ -2,6 +2,7 @@
/**
* @event {File[]} add
* @event {File[]} remove
* @event {File[]} change
*/
/**
@ -95,8 +96,8 @@
multiple="{multiple}"
kind="{kind}"
on:change
on:change="{({ target }) => {
files = [...target.files];
on:change="{(e) => {
files = e.detail;
}}"
/>
<div class:bx--file-container="{true}">

View file

@ -1,4 +1,8 @@
<script>
/**
* @event {File[]} change
*/
/**
* Specify the accepted file types
* @type {string[]}
@ -37,6 +41,10 @@
/** Obtain a reference to the input HTML element */
export let ref = null;
import { createEventDispatcher } from "svelte";
const dispatch = createEventDispatcher();
</script>
<label
@ -71,13 +79,14 @@
name="{name}"
class:bx--visually-hidden="{true}"
{...$$restProps}
on:change|stopPropagation
on:change|stopPropagation="{({ target }) => {
const files = target.files;
const length = files.length;
if (files && !disableLabelChanges) {
labelText = length > 1 ? `${length} files` : files[0].name;
}
dispatch('change', [...files]);
}}"
on:click
on:click="{({ target }) => {