Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Label.change event re-triggers itself #4309

Closed
1 task done
anentropic opened this issue May 22, 2023 · 1 comment · Fixed by #4371
Closed
1 task done

Label.change event re-triggers itself #4309

anentropic opened this issue May 22, 2023 · 1 comment · Fixed by #4371
Assignees
Labels
bug Something isn't working
Milestone

Comments

@anentropic
Copy link
Contributor

Describe the bug

The Label.change event fires when its value did not change

In fact the completion of handling the change event seems to re-trigger the change event

(I encountered this while trying to use a hidden Label as a workaround for State objects have no change event #2107)

Issue may be specific to the Label component, if I substitute a hidden Textbox the issue does not happen

Is there an existing issue for this?

  • I have searched the existing issues

Reproduction

import gradio as gr

def set_label(val):
    print("set_label")
    return f"> {val}"

def on_change(val):
    print(f"on_change: {val}")

with gr.Blocks() as demo:
    inp = gr.Textbox(label="Set label")
    label = gr.Label("", visible=False)

    inp.submit(set_label, [inp], [label])

    label.change(on_change, [label], None)

demo.launch(debug=True)

Screenshot

The code above gets stuck in a loop

Screenshot 2023-05-22 at 16 56 26

it seems like the change event re-triggers itself

Logs

n/a

System Info

gradio 3.32.0

Severity

annoying

@anentropic anentropic added the bug Something isn't working label May 22, 2023
@freddyaboulton
Copy link
Collaborator

Thanks @anentropic - will take a look!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants