The problem with using e.stopPropogation
with the ignoreRowClick
feature is it prevents any click events to children that expect it.
Case in point, a dropdown menu in a row needs the click event so it can maintain its state, or close other drop downs when the focus is changed
To solve this we can use an absolutely positioned div to act as a "Mask" or "Clip" for each TableCell that passes the onRowClicked handler to the "Clip" div instead of the TableCell. In other words, we no longer make the Row respond to click events, but the individual table cells.
When column.ignoreRowClick = true, it will not render a "Clip" div thereby making the TableCell "non-clickable"
Technically, onRowClick
doesn't make sense as a prop name, but it is less confusing than onTableCellClicked
as an api, giving the illusion that the row can be clicked when it's actually the "Clip" div that is listening for the click event.
To illustrate, the red masks are onRowClick
clickable cells and the white column is ignored (via ignoreRowClick
.
To mitigate performance issues with this approach, we can use event-delegation to prevent too TableCells from creating their own onclick event listener