Fix Dataframe select event firing twice on click#13010
Closed
gambletan wants to merge 2 commits intogradio-app:mainfrom
Closed
Fix Dataframe select event firing twice on click#13010gambletan wants to merge 2 commits intogradio-app:mainfrom
gambletan wants to merge 2 commits intogradio-app:mainfrom
Conversation
The select event was dispatched twice for a single click because handle_cell_click was called both in start_drag (mousedown) and end_drag (mouseup) when no drag occurred. Remove the redundant call from end_drag since start_drag already handles cell selection and event dispatch for non-drag clicks. Fixes gradio-app#12054
Member
|
Don’t delete our template. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #12054 — The Dataframe
.select()event handler fires twice for a single click.Root cause: In
js/dataframe/shared/utils/drag_utils.ts, thehandle_cell_clickfunction (which dispatches theselectevent) was called twice:start_drag(onmousedown) — correctly selects the cell and dispatchesselectend_drag(onmouseup) — redundantly callshandle_cell_clickagain when no drag occurred (!state.is_dragging && state.drag_start)Fix: Remove the redundant
handle_cell_clickcall fromend_drag. Thestart_draghandler already handles cell selection and event dispatch for simple (non-drag) clicks. Theend_draghandler only needs to clean up drag state and restore focus when an actual drag operation ends.This explains the behavior reported in the issue — a "hold click" (mousedown, wait, mouseup) fires the select event on both mousedown and mouseup, while a quick click may appear to fire once due to debouncing or timing.
Test plan
🤖 Generated with Claude Code