mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 18:31:06 +00:00
fix(file-uploader): FileUploader
change detail should be File[]
instead of FileList
(#1117)
Fixes #1112
This commit is contained in:
parent
dce0309bab
commit
7602731b0b
7 changed files with 38 additions and 18 deletions
|
@ -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}">
|
||||
|
|
|
@ -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 }) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue