Sometimes we need a link or button inside a cell and have onRowClick, but we don't want to fire 2 events, we just want to fire the event of the clicked (or enter press) element.
If you have focusable elements inside the cells, such as an or
Also, often we need to clear the padding on the cell and apply our own on cells from a certain column, DOing so via styled components is currently possible, but overcomplicated. So we add a custom field on the columns data: clearCellPadding, when passing this, we set the padding for all the cells in a specific column to 0.
For convenience, if using this plus renderCell, add a class name of fill-table-cell to the root element returned in renderCell to apply styles that will fill the cell with the correct padding (see default story).
Problem
Sometimes we need a link or button inside a cell and have
onRowClick
, but we don't want to fire 2 events, we just want to fire the event of the clicked (or enter press) element.Also, often we need to clear the padding on the cell and apply our own on cells from a certain column, DOing so via styled components is currently possible, but overcomplicated. So we add a custom field on the columns data:
clearCellPadding
, when passing this, we set the padding for all the cells in a specific column to 0.Story showcasing this: https://f8724e88.hsds-react.pages.dev/iframe?id=components-structural-table--default-story&args=&viewMode=story
Code example: