Skip to content

Fix Dataframe select event firing twice on click#13010

Closed
gambletan wants to merge 2 commits intogradio-app:mainfrom
gambletan:fix/dataframe-select-fires-twice
Closed

Fix Dataframe select event firing twice on click#13010
gambletan wants to merge 2 commits intogradio-app:mainfrom
gambletan:fix/dataframe-select-fires-twice

Conversation

@gambletan
Copy link
Copy Markdown
Contributor

Summary

Fixes #12054 — The Dataframe .select() event handler fires twice for a single click.

Root cause: In js/dataframe/shared/utils/drag_utils.ts, the handle_cell_click function (which dispatches the select event) was called twice:

  1. In start_drag (on mousedown) — correctly selects the cell and dispatches select
  2. In end_drag (on mouseup) — redundantly calls handle_cell_click again when no drag occurred (!state.is_dragging && state.drag_start)

Fix: Remove the redundant handle_cell_click call from end_drag. The start_drag handler already handles cell selection and event dispatch for simple (non-drag) clicks. The end_drag handler 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

  • Click a cell in a non-interactive Dataframe — select event should fire exactly once
  • Hold-click a cell (mousedown, wait ~1s, mouseup) — select event should fire exactly once
  • Drag across multiple cells — selection should still work correctly
  • Shift-click / Ctrl-click multi-select should still work
  • Verify with the reproduction script from the issue

🤖 Generated with Claude Code

Ethan T. and others added 2 commits March 13, 2026 13:34
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
@pngwn
Copy link
Copy Markdown
Member

pngwn commented Mar 13, 2026

Don’t delete our template.

@pngwn pngwn closed this Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Select event triggered twice for Dataframe object

3 participants