imballinst / react-bs-datatable

Bootstrap datatable without jQuery. Features include: filter, sort, pagination, checkbox, and control customization.
https://imballinst.github.io/react-bs-datatable
MIT License
60 stars 20 forks source link

Allow access to React event object for `onRowClick` #161

Closed Thomas-Boi closed 1 year ago

Thomas-Boi commented 1 year ago

Hi @imballinst,

I really like your package and find it very useful. I'd like to request one thing though: for the onRowClick callback, it'd be great if the React event object is passed in as a parameter.

onRowClick = function(rowData, event) {}

I need access to the target object of a click event and unfortunately, this is not allowing me to do so. I even consider overriding the onRowClick callback but it seems like passing in onclick via rowProps won't achieve what I want. image

It'd be great if you make the onRowClick callback accept a event argument. I can even do it myself via a MR if you would like that. However, since it's a small change, I thought perhaps you can add it in to another release.

image

Thank you for your time and I'd like to see this feature soon.

imballinst commented 1 year ago

hi @Thomas-Boi, thanks for using this library! I think that's a valid feature request, I'll see what I can do today and yes, this API looks good to me!

onRowClick = function(rowData, event) {}

I'll get back to to you after I have published the beta version of the feature so that you could test it.

imballinst commented 1 year ago

hi @Thomas-Boi, I have published 3.7.0-beta.0 and here is the demo: https://codesandbox.io/s/keen-cartwright-9xph1b?file=/src/App.tsx. Feel free to play around and let me know if there are things that are still missing!

If all are good, then I'll merge the PR and publish 3.7.0.

Thomas-Boi commented 1 year ago

Thanks so much @imballinst for getting this done so quickly! I tested the feature and it works as expected. This would help me a lot with dynamically rendering some components via createPortal and absolute positing.

Thomas-Boi commented 1 year ago

One thing I've noticed though: the button onclick would need to manually call event.stopPropagation to prevent double event handler. This is fine with me and I'll just leave this comment here as documentations for future users.

imballinst commented 1 year ago

Sounds good to me! I'll merge the PR then I'll publish 3.7.0. Thanks for the confirmation!

One thing I've noticed though: the button onclick would need to manually call event.stopPropagation to prevent double event handler. This is fine with me and I'll just leave this comment here as documentations for future users.

Oh yes, that's a good point, I forgot to handle that in the sandbox.

imballinst commented 1 year ago

3.7.0 has been published to npm: https://www.npmjs.com/package/react-bs-datatable/v/3.7.0