diff --git a/frontend/src/components/DataGrid.ddl.test.tsx b/frontend/src/components/DataGrid.ddl.test.tsx index 8cb87ea9..ac2a5e7f 100644 --- a/frontend/src/components/DataGrid.ddl.test.tsx +++ b/frontend/src/components/DataGrid.ddl.test.tsx @@ -1073,7 +1073,7 @@ describe('DataGrid DDL interactions', () => { vi.unstubAllGlobals(); }); - it('selects one row when its row number cell is clicked', async () => { + it('toggles one row when its row number cell is clicked', async () => { storeState.appearance.uiVersion = 'v2'; const rows = [ { [GONAVI_ROW_KEY]: 'row-1', id: 1 }, @@ -1107,6 +1107,14 @@ describe('DataGrid DDL interactions', () => { expect(stopPropagation).toHaveBeenCalledTimes(1); expect(testRenderState.latestTableProps.rowHoverable).toBe(false); expect(testRenderState.latestTableProps.rowSelection.selectedRowKeys).toEqual(['row-2']); + + await act(async () => { + rowNumberColumn.onCell(rows[1], 1).onClick({ stopPropagation }); + }); + await waitForEffects(); + + expect(stopPropagation).toHaveBeenCalledTimes(2); + expect(testRenderState.latestTableProps.rowSelection.selectedRowKeys).toEqual([]); renderer!.unmount(); }); diff --git a/frontend/src/components/DataGrid.tsx b/frontend/src/components/DataGrid.tsx index 0f4d203c..03cda76f 100644 --- a/frontend/src/components/DataGrid.tsx +++ b/frontend/src/components/DataGrid.tsx @@ -3381,7 +3381,9 @@ const DataGrid: React.FC = ({ const handleRowNumberClick = useCallback((record: Item) => { const key = record?.[GONAVI_ROW_KEY]; if (key === undefined || key === null) return; - setSelectedRowKeys([key]); + setSelectedRowKeys((previousKeys) => ( + previousKeys.length === 1 && previousKeys[0] === key ? [] : [key] + )); }, []); const handleRowNumberDoubleClick = useCallback((index: number) => {