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

Event Bubbling between Dropdown and Slider #9308

Open
1 task done
harisreedhar opened this issue Sep 10, 2024 · 2 comments
Open
1 task done

Event Bubbling between Dropdown and Slider #9308

harisreedhar opened this issue Sep 10, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@harisreedhar
Copy link

harisreedhar commented Sep 10, 2024

Describe the bug

Choosing a value from the dropdown is causing the underlying slider to trigger a mouseup event. To fix this, we probably need to apply event.stopPropagation(). In the provided video, I added an event handler to the slider to illustrate the problem

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction

import gradio as gr


def handle_slider_change(slider_value):
	print(f"Slider value changed to: {slider_value}")
	return slider_value


def handle_dropdown_change(dropdown_value):
	print(f"Dropdown value changed to: {dropdown_value}")
	return dropdown_value


with gr.Blocks() as demo:
	dropdown = gr.Dropdown(
		choices = ["Option 1", "Option 2", "Option 3", "Option 4", "Option 5"],
		label = "Select an option",
		value = "Option 1"
	)
	slider = gr.Slider(minimum = 0, maximum = 100, step = 1, label = "Select a value", value = 50)

	dropdown.change(handle_dropdown_change, inputs = dropdown)
	slider.release(handle_slider_change, inputs = slider)


demo.launch()

Screenshot

Screencast.from.10-09-24.13_37_18.webm

Logs

No response

System Info

Gradio Environment Information:
------------------------------
Operating System: Linux
gradio version: 4.43.0
gradio_client version: 1.3.0

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

aiofiles: 23.2.1
anyio: 4.4.0
fastapi: 0.112.1
ffmpy: 0.4.0
gradio-client==1.3.0 is not installed.
httpx: 0.27.0
huggingface-hub: 0.24.6
importlib-resources: 6.4.4
jinja2: 3.1.4
markupsafe: 2.1.5
matplotlib: 3.9.2
numpy: 1.26.4
orjson: 3.10.7
packaging: 24.1
pandas: 2.2.2
pillow: 10.4.0
pydantic: 2.8.2
pydub: 0.25.1
python-multipart: 0.0.9
pyyaml: 6.0.2
ruff: 0.6.2
semantic-version: 2.10.0
tomlkit==0.12.0 is not installed.
typer: 0.12.4
typing-extensions: 4.12.2
urllib3: 2.2.2
uvicorn: 0.30.6
authlib; extra == 'oauth' is not installed.
itsdangerous; extra == 'oauth' is not installed.


gradio_client dependencies in your environment:

fsspec: 2024.6.1
httpx: 0.27.0
huggingface-hub: 0.24.6
packaging: 24.1
typing-extensions: 4.12.2
websockets: 12.0

Severity

Blocking usage of gradio

@harisreedhar harisreedhar added the bug Something isn't working label Sep 10, 2024
@pngwn
Copy link
Member

pngwn commented Sep 10, 2024

Can you provide a reproduction of this causing an issue please.

@harisreedhar
Copy link
Author

harisreedhar commented Sep 10, 2024

Can you provide a reproduction of this causing an issue please.

Updated with reproduction code. When option 2 in the dropdown is clicked, the slider under it also triggers.
image

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