Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Commit 3e31a7f

Browse files
committed
fix cell click logic for clicking the active cell again
1 parent 1c69cfb commit 3e31a7f

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

src/dash-table/handlers/cellEvents.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ export const handleClick = (propsFn: () => ICellFactoryProps, idx: number, i: nu
1515
viewport
1616
} = propsFn();
1717

18+
const row = idx + virtualized.offset.rows;
19+
const col = i + virtualized.offset.columns;
20+
21+
const clickedCell = makeCell(row, col, columns, viewport);
22+
23+
// clicking again on the already-active cell: ignore
24+
if (active_cell && row === active_cell.row && col === active_cell.column) {
25+
return;
26+
}
27+
1828
e.preventDefault();
1929

2030
/*
@@ -27,15 +37,11 @@ export const handleClick = (propsFn: () => ICellFactoryProps, idx: number, i: nu
2737
*/
2838
window.getSelection().removeAllRanges();
2939

30-
const row = idx + virtualized.offset.rows;
31-
const col = i + virtualized.offset.columns;
32-
33-
const clickedCell = makeCell(row, col, columns, viewport);
34-
3540
const selected = isSelected(selected_cells, row, col);
3641

37-
// if clicking on an already-selected cell (NOT shift-clicking),
38-
// don't alter the selection, just move the active cell
42+
// if clicking on a *different* already-selected cell (NOT shift-clicking,
43+
// not the active cell), don't alter the selection,
44+
// just move the active cell
3945
if (selected && !e.shiftKey) {
4046
setProps({
4147
is_focused: false,

0 commit comments

Comments
 (0)