Skip to content

fix: prevent duplicate select event dispatch in Dataframe component#13009

Closed
gambletan wants to merge 1 commit intogradio-app:mainfrom
gambletan:fix/dataframe-duplicate-select
Closed

fix: prevent duplicate select event dispatch in Dataframe component#13009
gambletan wants to merge 1 commit intogradio-app:mainfrom
gambletan:fix/dataframe-duplicate-select

Conversation

@gambletan
Copy link
Copy Markdown
Contributor

Summary

Fixes #12054

  • The select event was being dispatched twice when clicking a Dataframe cell because handle_cell_click was called both on mousedown (in start_drag) and on mouseup (in end_drag) in drag_utils.ts
  • Removed the redundant handle_cell_click call from end_drag, since start_drag already handles the cell click and select event dispatch for non-drag (simple click) interactions
  • Drag selection behavior is preserved as end_drag only needs to clean up drag state and restore focus

Test plan

  • Click on a Dataframe cell and verify the select event handler (fn in .select(fn=...)) is called exactly once
  • Verify drag-to-select multiple cells still works correctly
  • Verify shift-click and ctrl/cmd-click selection still works
  • Test with the reproduction script from the issue to confirm "clicked" is printed once per click

When clicking a cell, handle_cell_click was called both on mousedown
(in start_drag) and on mouseup (in end_drag), causing the select event
to fire twice. Remove the redundant call in end_drag since start_drag
already handles cell click for non-drag interactions.

Fixes gradio-app#12054
@pngwn
Copy link
Copy Markdown
Member

pngwn commented Mar 13, 2026

Don’t delete our template. Disclosure rules not followed

@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

2 participants