Skip to content

Commit

Permalink
feat: add event in cell click handler (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marginy605 authored May 5, 2023
1 parent a6f877a commit 11e7a00
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lib/DataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1185,8 +1185,9 @@ class DataTableView<T> extends React.Component<DataTableProps<T>, DataTableViewS

const _getOnClick =
typeof onClick === 'function'
? (data: {row: T; index: number; footer?: boolean; headerData?: boolean}) => () =>
onClick(data, column)
? (data: {row: T; index: number; footer?: boolean; headerData?: boolean}) =>
(event: React.MouseEvent<HTMLTableCellElement>) =>
onClick(data, column, event)
: () => undefined;

return {
Expand Down
1 change: 1 addition & 0 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export interface Column<T> {
onClick?: (
data: {row: T; index: number; footer?: boolean; headerData?: boolean},
column: Column<T>,
event: React.MouseEvent<HTMLTableCellElement>,
) => void;

sortable?: boolean;
Expand Down

0 comments on commit 11e7a00

Please sign in to comment.