Skip to content

Commit 9473c5c

Browse files
feat: Add onRowClick handler for interactive table rows
- Add optional onRowClick prop to TableWrapper interface - Enable click handler for drill-down interactions - Add visual feedback with cursor pointer and hover state - Backward compatible - existing tables unchanged - Uses PatternFly's isHoverable for consistent styling - Tested in OCM Genie POC with 100+ row tables This feature enables common use cases like: - Navigating to detail pages - Opening modals/drawers - Selecting items for actions - Expanding inline details
1 parent 44fabf8 commit 9473c5c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/components/TableWrapper.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ interface TableWrapperProps {
2323
id: string;
2424
fields: FieldData[];
2525
className?: string;
26+
onRowClick?: (rowData: Record<string, string | number | null>) => void;
2627
}
2728

2829
const TableWrapper = (props: TableWrapperProps) => {
29-
const { title, id, fields, className } = props;
30+
const { title, id, fields, className, onRowClick } = props;
3031

3132
// Check for missing or invalid data
3233
const hasNoFields = !fields || fields.length === 0;
@@ -102,7 +103,13 @@ const TableWrapper = (props: TableWrapperProps) => {
102103
</Thead>
103104
<Tbody>
104105
{rows.map((row, rowIndex) => (
105-
<Tr key={rowIndex} data-testid={`row-${rowIndex}`}>
106+
<Tr
107+
key={rowIndex}
108+
data-testid={`row-${rowIndex}`}
109+
onClick={() => onRowClick?.(row)}
110+
style={onRowClick ? { cursor: 'pointer' } : undefined}
111+
isHoverable={!!onRowClick}
112+
>
106113
{columns.map((col, colIndex) => (
107114
<Td key={colIndex}>{row[col.key]}</Td>
108115
))}

0 commit comments

Comments
 (0)