Skip to content

Commit b9b8d08

Browse files
lara-gfariaabidlabsgradio-pr-bot
authored
Fix disabling buttons in MultimodalTextbox when interactive=False (#10902)
* Fix #9967: interactive=False not disabling buttons In the MultimodalTextbox component, when interactive=False, the submit button remained active allowing users to submit inputs without being able to edit them. To fix this, I added restrictions to disable the submit, file upload and microphone buttons when interactive=False. * format * add changeset --------- Co-authored-by: Abubakar Abid <[email protected]> Co-authored-by: gradio-pr-bot <[email protected]>
1 parent 2de9f57 commit b9b8d08

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

.changeset/plain-moments-cover.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@gradio/multimodaltextbox": patch
3+
"gradio": patch
4+
---
5+
6+
fix:Fix disabling buttons in `MultimodalTextbox` when `interactive=False`

js/multimodaltextbox/shared/MultimodalTextbox.svelte

+18-11
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@
388388
/>
389389
{/if}
390390
<div class="input-container">
391-
{#if sources && sources.includes("upload") && !disabled && !(file_count === "single" && value.files.length > 0)}
391+
{#if sources && sources.includes("upload") && !(file_count === "single" && value.files.length > 0)}
392392
<Upload
393393
bind:this={upload_component}
394394
on:load={handle_upload}
@@ -409,17 +409,23 @@
409409
<button
410410
data-testid="upload-button"
411411
class="upload-button"
412-
on:click={handle_upload_click}><Paperclip /></button
412+
{disabled}
413+
on:click={disabled ? undefined : handle_upload_click}
414+
><Paperclip /></button
413415
>
414416
{/if}
415417
{#if sources && sources.includes("microphone")}
416418
<button
417419
data-testid="microphone-button"
418420
class="microphone-button"
419421
class:recording
420-
on:click={() => {
421-
active_source = active_source !== "microphone" ? "microphone" : null;
422-
}}
422+
{disabled}
423+
on:click={disabled
424+
? undefined
425+
: () => {
426+
active_source =
427+
active_source !== "microphone" ? "microphone" : null;
428+
}}
423429
>
424430
<Microphone />
425431
</button>
@@ -453,7 +459,8 @@
453459
<button
454460
class="submit-button"
455461
class:padded-button={submit_btn !== true}
456-
on:click={handle_submit}
462+
{disabled}
463+
on:click={disabled ? undefined : handle_submit}
457464
>
458465
{#if submit_btn === true}
459466
<Send />
@@ -567,10 +574,10 @@
567574
background: var(--button-secondary-background-fill);
568575
}
569576
570-
.microphone-button:hover,
571-
.stop-button:hover,
572-
.upload-button:hover,
573-
.submit-button:hover {
577+
.microphone-button:hover:not(:disabled),
578+
.stop-button:hover:not(:disabled),
579+
.upload-button:hover:not(:disabled),
580+
.submit-button:hover:not(:disabled) {
574581
background: var(--button-secondary-background-fill-hover);
575582
}
576583
@@ -579,7 +586,7 @@
579586
.upload-button:disabled,
580587
.submit-button:disabled {
581588
background: var(--button-secondary-background-fill);
582-
cursor: initial;
589+
cursor: not-allowed;
583590
}
584591
.microphone-button:active,
585592
.stop-button:active,

0 commit comments

Comments
 (0)