I'm using the react-data-table-component
.
I have these columns:
const columns = [
{
name: 'ID',
selector: 'id',
sortable: true,
},
{
name: 'Place',
selector: 'place',
sortable: true,
},
{
name: 'Created at',
sortable: true,
selector: 'created_at',
cell: row => new Date(row.created_at).toLocaleDateString()
},
{
name: '',
sortable: false,
cell: () => <Button variant="danger" data-tag="allowRowEvents" data-action="delete"><FontAwesomeIcon icon={faTrash} /></Button>,
}
]
And in Datatable
component:
const handleRowClicked = ({id}, e) => {
e.stopPropagation()
const action = e.target.getAttribute('data-action')
switch (action) {
case 'show':
props.openModalDetail(id);
break;
case 'delete':
props.delete(id)
break
default:
return
}
return
}
The event is listend on click on button (every pixel of red square) but not on icon itself.
I did try to add the data-tag="allowRowEvents"
on icon itself, without success.
I did try to add a listener to e.currentTarget
, without success.