File tree Expand file tree Collapse file tree 1 file changed +12
-9
lines changed
packages/react/src/file-upload Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -101,11 +101,14 @@ export const Required: Story = {
101101 onSubmit = { ( e ) => {
102102 e . preventDefault ( ) ;
103103 const formData = new FormData ( e . target as HTMLFormElement ) ;
104+ const files = formData
105+ . getAll ( 'files' )
106+ . filter (
107+ ( file ) => file instanceof File && file . size > 0 && file . name ,
108+ ) ;
109+
104110 alert (
105- `Lastet opp ${ formData
106- . getAll ( 'files' )
107- . map ( ( file ) => ( file as File ) . name )
108- . join ( ', ' ) } `,
111+ `Lastet opp ${ files . map ( ( file ) => ( file as File ) . name ) . join ( ', ' ) } ` ,
109112 ) ;
110113 } }
111114 >
@@ -143,17 +146,17 @@ export const InForm = () => (
143146 onSubmit = { ( e ) => {
144147 e . preventDefault ( ) ;
145148 const formData = new FormData ( e . target as HTMLFormElement ) ;
149+ const files = formData
150+ . getAll ( 'files' )
151+ . filter ( ( file ) => file instanceof File && file . size > 0 && file . name ) ;
152+
146153 alert (
147- `Lastet opp ${ formData
148- . getAll ( 'files' )
149- . map ( ( file ) => ( file as File ) . name )
150- . join ( ', ' ) } `,
154+ `Lastet opp ${ files . map ( ( file ) => ( file as File ) . name ) . join ( ', ' ) } ` ,
151155 ) ;
152156 } }
153157 >
154158 < FileUpload
155159 validate = { ( file ) => file . size < 1000000 || 'Filen er for stor' }
156- isRequired
157160 allowsMultiple
158161 name = "files"
159162 >
You can’t perform that action at this time.
0 commit comments