Skip to content

Commit 6ec3cd8

Browse files
author
BillionClaw
committed
fix(dataframe): prevent interface freeze on cell selection with Ctrl
When selecting a DataFrame cell with mousedown, then pressing Ctrl before mouseup, the interface would freeze. This happened because handle_cell_click was being called twice - once during mousedown and once during mouseup - causing conflicting selection state updates. The fix adds a click_handled flag to track whether the cell click has already been processed during mousedown, preventing duplicate handling during mouseup. Fixes #13020
1 parent 356db5c commit 6ec3cd8

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

js/dataframe/shared/Table.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,8 @@
772772
const drag_state: DragState = {
773773
is_dragging,
774774
drag_start,
775-
mouse_down_pos
775+
mouse_down_pos,
776+
click_handled: false
776777
};
777778
778779
$: {

js/dataframe/shared/utils/drag_utils.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export type DragState = {
55
is_dragging: boolean;
66
drag_start: CellCoordinate | null;
77
mouse_down_pos: { x: number; y: number } | null;
8+
click_handled: boolean;
89
};
910

1011
export type DragHandlers = {
@@ -41,11 +42,13 @@ export function create_drag_handlers(
4142

4243
state.mouse_down_pos = { x: event.clientX, y: event.clientY };
4344
state.drag_start = [row, col];
45+
state.click_handled = false;
4446

4547
if (!event.shiftKey && !event.metaKey && !event.ctrlKey) {
4648
set_selected_cells([[row, col]]);
4749
set_selected([row, col]);
4850
handle_cell_click(event, row, col);
51+
state.click_handled = true;
4952
}
5053
};
5154

@@ -64,7 +67,9 @@ export function create_drag_handlers(
6467
};
6568

6669
const end_drag = (event: MouseEvent): void => {
67-
if (!state.is_dragging && state.drag_start) {
70+
if (!state.is_dragging && state.drag_start && !state.click_handled) {
71+
// If the cell wasn't already processed during mousedown (due to modifier keys),
72+
// handle it now on mouseup
6873
handle_cell_click(event, state.drag_start[0], state.drag_start[1]);
6974
} else if (state.is_dragging && parent_element) {
7075
parent_element.focus();
@@ -74,6 +79,7 @@ export function create_drag_handlers(
7479
set_is_dragging(false);
7580
state.drag_start = null;
7681
state.mouse_down_pos = null;
82+
state.click_handled = false;
7783
};
7884

7985
return {

0 commit comments

Comments
 (0)