mirror of
https://github.com/gradio-app/gradio.git
synced 2025-03-31 12:20:26 +08:00
Fix Label component's value change detection to avoid infinite loop dispatching the change event (#8054)
* Fix Label component's value change detection to avoid infinite loop dispatching the change event * add changeset * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
This commit is contained in:
parent
367a20c525
commit
176a8a4d71
6
.changeset/silly-drinks-glow.md
Normal file
6
.changeset/silly-drinks-glow.md
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
"@gradio/label": patch
|
||||
"gradio": patch
|
||||
---
|
||||
|
||||
feat:Fix Label component's value change detection to avoid infinite loop dispatching the change event
|
@ -23,6 +23,7 @@
|
||||
label?: string;
|
||||
confidences?: { label: string; confidence: number }[];
|
||||
} = {};
|
||||
let old_value: typeof value | null = null;
|
||||
export let label = gradio.i18n("label.label");
|
||||
export let container = true;
|
||||
export let scale: number | null = null;
|
||||
@ -31,8 +32,14 @@
|
||||
export let show_label = true;
|
||||
export let _selectable = false;
|
||||
|
||||
$: ({ confidences, label: _label } = value);
|
||||
$: _label, confidences, gradio.dispatch("change");
|
||||
$: {
|
||||
if (JSON.stringify(value) !== JSON.stringify(old_value)) {
|
||||
old_value = value;
|
||||
gradio.dispatch("change");
|
||||
}
|
||||
}
|
||||
|
||||
$: _label = value.label;
|
||||
</script>
|
||||
|
||||
<Block
|
||||
|
Loading…
x
Reference in New Issue
Block a user