Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/DataGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export interface DataGridHandle {
element: HTMLDivElement | null;
scrollToCell: (position: PartialPosition) => void;
selectCell: (position: Position, options?: SelectCellOptions) => void;
unselectCell: () => void;
}

type SharedDivProps = Pick<
Expand Down Expand Up @@ -547,7 +548,8 @@ export function DataGrid<R, SR = unknown, K extends Key = Key>(props: DataGridPr
setScrollToPosition({ idx: scrollToIdx, rowIdx: scrollToRowIdx });
}
},
selectCell
selectCell,
unselectCell
})
);

Expand Down Expand Up @@ -859,6 +861,13 @@ export function DataGrid<R, SR = unknown, K extends Key = Key>(props: DataGridPr
}
}

function unselectCell(): void {
commitEditorChanges();

setShouldFocusCell(false);
setSelectedPosition({ idx: -1, rowIdx: minRowIdx - 1, mode: 'SELECT' });
}

function selectHeaderCell({ idx, rowIdx }: Position): void {
selectCell({ rowIdx: minRowIdx + rowIdx - 1, idx });
}
Expand Down