Skip to content

Commit

Permalink
EDS Data Grid Feature: +onRowDoubleClick event (#3718)
Browse files Browse the repository at this point in the history
* +onRowDoubleClick event to the table

* fix prettier issue
  • Loading branch information
oleksiishv authored Jan 8, 2025
1 parent 931b82d commit 0886e92
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/eds-data-grid-react/src/EdsDataGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ function EdsDataGridInner<T>(
defaultColumn,
onRowContextMenu,
onRowClick,
onRowDoubleClick,
onCellClick,
enableFooter,
enableSortingRemoval,
Expand Down Expand Up @@ -485,6 +486,11 @@ function EdsDataGridInner<T>(
? (event) => onRowClick(row, event)
: undefined
}
onDoubleClick={
onRowDoubleClick
? (event) => onRowDoubleClick(row, event)
: undefined
}
onCellClick={onCellClick}
/>
)
Expand Down
11 changes: 11 additions & 0 deletions packages/eds-data-grid-react/src/EdsDataGridProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,17 @@ type HandlersProps<T> = {
* @returns
*/
onRowClick?: (row: Row<T>, event: MouseEvent<HTMLTableRowElement>) => unknown
/**
* Row double-click handler.
*
* @param row The current row
* @param event The click event
* @returns
*/
onRowDoubleClick?: (
row: Row<T>,
event: MouseEvent<HTMLTableRowElement>,
) => unknown
/**
* Cell click handler.
*
Expand Down
2 changes: 2 additions & 0 deletions packages/eds-data-grid-react/src/components/TableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export function TableRow<T>({
row,
onCellClick,
onClick,
onDoubleClick,
onContextMenu,
}: Props<T>) {
const { rowClass, rowStyle } = useTableContext()
Expand All @@ -26,6 +27,7 @@ export function TableRow<T>({
}}
className={`${row.getIsSelected() ? 'selected' : ''} ${rowClass?.(row)}`}
onClick={onClick}
onDoubleClick={onDoubleClick}
onContextMenu={onContextMenu}
>
{row.getVisibleCells().map((cell) => (
Expand Down

0 comments on commit 0886e92

Please sign in to comment.