Skip to content

Commit

Permalink
Add handle function for DataGrid
Browse files Browse the repository at this point in the history
  • Loading branch information
plcdev committed May 30, 2024
1 parent bc23189 commit 3ec1683
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/DataGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export interface DataGridHandle {
scrollToColumn: (colIdx: number) => void;
scrollToRow: (rowIdx: number) => void;
selectCell: (position: Position, enableEditor?: Maybe<boolean>) => void;
clearSelectCell: () => void;
}

type SharedDivProps = Pick<
Expand Down Expand Up @@ -385,7 +386,8 @@ function DataGrid<R, SR, K extends Key>(
behavior: 'smooth'
});
},
selectCell
selectCell,
clearSelectCell
}));

/**
Expand Down Expand Up @@ -709,6 +711,14 @@ function DataGrid<R, SR, K extends Key>(
}
}

/**
* Clear selected cell with initial value.
*/
function clearSelectCell(): void {
setSelectedPosition(initialPosition);
setDraggedOverRowIdx(undefined);
}

function closeEditor() {
if (selectedPosition.mode === 'SELECT') return;
setSelectedPosition(({ idx, rowIdx }) => ({ idx, rowIdx, mode: 'SELECT' }));
Expand Down

0 comments on commit 3ec1683

Please sign in to comment.