File tree 4 files changed +62
-37
lines changed
4 files changed +62
-37
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @gradio/file " : patch
3
+ " @gradio/multimodaltextbox " : patch
4
+ " gradio " : patch
5
+ ---
6
+
7
+ fix: Hide upload button after upload when ` file_count="single" `
Original file line number Diff line number Diff line change 61
61
62
62
{#if value && (Array .isArray (value ) ? value .length > 0 : true )}
63
63
<IconButtonWrapper >
64
- <IconButton Icon ={UploadIcon } label ={i18n (" common.upload" )}>
65
- <Upload
66
- icon _upload={true }
67
- on:load ={handle_upload }
68
- filetype ={file_types }
69
- {file_count }
70
- {max_file_size }
71
- {root }
72
- bind:dragging
73
- bind:uploading
74
- on:error
75
- {stream_handler }
76
- {upload }
77
- />
78
- </IconButton >
64
+ {#if ! (file_count === " single" && (Array .isArray (value ) ? value .length > 0 : value !== null ))}
65
+ <IconButton Icon ={UploadIcon } label ={i18n (" common.upload" )}>
66
+ <Upload
67
+ icon _upload={true }
68
+ on:load ={handle_upload }
69
+ filetype ={file_types }
70
+ {file_count }
71
+ {max_file_size }
72
+ {root }
73
+ bind:dragging
74
+ bind:uploading
75
+ on:error
76
+ {stream_handler }
77
+ {upload }
78
+ />
79
+ </IconButton >
80
+ {/if }
79
81
<IconButton
80
82
Icon ={Clear }
81
83
label ={i18n (" common.clear" )}
Original file line number Diff line number Diff line change 73
73
/>
74
74
<Story name ="Right aligned textbox" args ={{ text_align : " right" }} />
75
75
<Story name ="RTL textbox" args ={{ rtl : true }} />
76
+ <Story
77
+ name =" Single file upload"
78
+ args ={{
79
+ file_count : " single" ,
80
+ value : {
81
+ text : " sample text" ,
82
+ files : [
83
+ {
84
+ path: " https://gradio-builds.s3.amazonaws.com/demo-files/ghepardo-primo-piano.jpg"
85
+ }
86
+ ]
87
+ }
88
+ }}
89
+ />
Original file line number Diff line number Diff line change 315
315
</div >
316
316
{/if }
317
317
<div class =" input-container" >
318
- <Upload
319
- bind:this ={upload_component }
320
- on:load ={handle_upload }
321
- {file_count }
322
- filetype ={file_types }
323
- {root }
324
- {max_file_size }
325
- bind:dragging
326
- bind:uploading
327
- show _progress={false }
328
- disable _click={true }
329
- bind:hidden _upload
330
- on:error
331
- hidden ={true }
332
- {upload }
333
- {stream_handler }
334
- ></Upload >
335
- <button
336
- data-testid =" upload-button"
337
- class =" upload-button"
338
- on:click ={handle_upload_click }><Paperclip /></button
339
- >
318
+ {#if ! disabled && ! (file_count === " single" && value .files .length > 0 )}
319
+ <Upload
320
+ bind:this ={upload_component }
321
+ on:load ={handle_upload }
322
+ {file_count }
323
+ filetype ={file_types }
324
+ {root }
325
+ {max_file_size }
326
+ bind:dragging
327
+ bind:uploading
328
+ show _progress={false }
329
+ disable _click={true }
330
+ bind:hidden _upload
331
+ on:error
332
+ hidden ={true }
333
+ {upload }
334
+ {stream_handler }
335
+ ></Upload >
336
+ <button
337
+ data-testid =" upload-button"
338
+ class =" upload-button"
339
+ on:click ={handle_upload_click }><Paperclip /></button
340
+ >
341
+ {/if }
340
342
<textarea
341
343
data-testid =" textbox"
342
344
use:text _area_resize={{
You can’t perform that action at this time.
0 commit comments