gradio
gradio copied to clipboard
Ensure that all prop changes are tracked at the top level
Describe the bug
We current'y update the component tree pretty aggressively, rootNode = rootNode in certain case this can lead to the entire component updateing. This isn't necessarily a huge issue but we don't always have a reference to the exact state of certain components because we do not track the values of every prop when they are changed from inside of the component.
Normally this isn't an issue because we don't set that value again but it you update a prop with gr.Update() or component(**kwargs) then there can be a discrepancy between the props value internally and the value we hold at the top level. This can lead to weird behaviour in certain instances.
I do not not fully understand the impact of this issue but it was the reason for #6276 and i suspect it has an impact on other components.
Have you searched existing issues? 🔎
- [X] I have searched and found no existing issues
Reproduction
Screenshot
Logs
-
System Info
-
Severity
I can work around it
I think I noticed that as well.
My use case was a button B that called function f.
Before f is called, B has value "UNDEFINED". As soon as f is called: it returns gr.update(value="name") direclty to B. So far so good: for the user the text appearing on B is now "name" after clicking.
But when clicking again on B, f now checks evt.target.value to see the name of the button that called it. I expected the value to be "name" but it was instead "UNDEFINED".
I ended up working around it by setting elem_id of my buttons so that I can keep track of what button called no matter their name but still this is a bug.
This was fixed in 4.0.