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

Code component event listeners not working properly when being dynamically rendered with gr.render #8670

Open
1 task done
z3lx opened this issue Jun 30, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@z3lx
Copy link

z3lx commented Jun 30, 2024

Describe the bug

The event listeners for the gr.Code component does not seem to work properly when used in a function with the gr.render decorator.

  • Code.change and Code.input does not trigger properly, instead triggers only once per re-render.
  • Code.change, Code.input, Code.focus and Code.blur does not return the entered code, instead returns the component's initial value.

These issues are not observed when using a gr.Textbox or a gr.TextArea.

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction

import gradio as gr

def identity(v):
    print(v)
    return v

with gr.Blocks() as demo:
    show_checkbox = gr.Checkbox(label="Show", value=True)
    text_state = gr.State("Some text")

    @gr.render(inputs=[show_checkbox, text_state])
    def render(show: bool, text: str) -> None:
        if not show:
            return
        text_input = gr.Code(
            value=text,
        )
        text_input.input(
            fn=identity,
            inputs=[text_input],
            outputs=[text_state],
        )

demo.launch()

Screenshot

No response

Logs

No response

System Info

Gradio Environment Information:
------------------------------
Operating System: Windows
gradio version: 4.37.2
gradio_client version: 1.0.2

------------------------------------------------
gradio dependencies in your environment:

aiofiles: 23.2.1
altair: 5.3.0
fastapi: 0.111.0
ffmpy: 0.3.2
gradio-client==1.0.2 is not installed.
httpx: 0.27.0
huggingface-hub: 0.23.3
importlib-resources: 6.4.0
jinja2: 3.1.3
markupsafe: 2.1.5
matplotlib: 3.9.0
numpy: 1.26.3
orjson: 3.10.5
packaging: 24.1
pandas: 2.2.2
pillow: 10.2.0
pydantic: 2.7.3
pydub: 0.25.1
python-multipart: 0.0.9
pyyaml: 6.0.1
ruff: 0.4.9
semantic-version: 2.10.0
tomlkit==0.12.0 is not installed.
typer: 0.12.3
typing-extensions: 4.9.0
urllib3: 2.2.1
uvicorn: 0.30.1
authlib; extra == 'oauth' is not installed.
itsdangerous; extra == 'oauth' is not installed.


gradio_client dependencies in your environment:

fsspec: 2024.2.0
httpx: 0.27.0
huggingface-hub: 0.23.3
packaging: 24.1
typing-extensions: 4.9.0
websockets: 11.0.3

Severity

I can work around it

@z3lx z3lx added the bug Something isn't working label Jun 30, 2024
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

No branches or pull requests

1 participant