Skip to content

Commit

Permalink
Trigger input event for Radio even when radio is output component (#7762
Browse files Browse the repository at this point in the history
)

* Add code

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
  • Loading branch information
freddyaboulton and gradio-pr-bot committed Mar 20, 2024
1 parent 9f8313f commit e78bca4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
6 changes: 6 additions & 0 deletions .changeset/mighty-bags-begin.md
@@ -0,0 +1,6 @@
---
"@gradio/radio": patch
"gradio": patch
---

fix:Trigger input event for Radio even when radio is output component
13 changes: 4 additions & 9 deletions js/radio/Index.svelte
Expand Up @@ -23,7 +23,6 @@
export let elem_classes: string[] = [];
export let visible = true;
export let value: string | null = null;
export let value_is_output = false;
export let choices: [string, string | number][] = [];
export let show_label = true;
export let container = false;
Expand All @@ -34,14 +33,8 @@
function handle_change(): void {
gradio.dispatch("change");
if (!value_is_output) {
gradio.dispatch("input");
}
}
afterUpdate(() => {
value_is_output = false;
});
$: value, handle_change();
$: disabled = !interactive;
Expand Down Expand Up @@ -71,8 +64,10 @@
{internal_value}
bind:selected={value}
{disabled}
on:input={() =>
gradio.dispatch("select", { value: internal_value, index: i })}
on:input={() => {
gradio.dispatch("select", { value: internal_value, index: i });
gradio.dispatch("input");
}}
/>
{/each}
</div>
Expand Down

0 comments on commit e78bca4

Please sign in to comment.