Middle mouse click support #380
Replies: 6 comments 2 replies
-
Hey @DimitriosProvatas, Thanks for using Mantine DataTable and for your suggestion. However, I think there is a way to easily implement this in a generic way with only a minor change to the current codebase. customRowAttributes?: (record: T, recordIndex: number) => Record<string, string | number>; and customCellAttributes?: (record: T, recordIndex: number) => Record<string, string | number>; I could change the function return types to something more generic, like <DataTable
columns={[{ accessor: 'name' }, { accessor: 'city' }, { accessor: 'state' }]}
// other props...
customRowAttributes={({ id, name }, recordIndex) => ({
onAuxClick: () => alert(`Middle-click on row ${name}`),
})}
/> This would be a non-breaking change, we would not bloat the codebase with edge-case properties, and people would still be able to handle middle clicks. What do you think? |
Beta Was this translation helpful? Give feedback.
-
UPDATE: <DataTable
columns={[{ accessor: 'name' }, { accessor: 'city' }, { accessor: 'state' }]}
// other props...
customRowAttributes={({ id, name }, recordIndex) => ({
onMouseDown: (e: MouseEvent) => {
if (e.button === 1) {
alert(`Middle-click on row ${name}`);
}
},
})}
/> |
Beta Was this translation helpful? Give feedback.
-
Ok, then. |
Beta Was this translation helpful? Give feedback.
-
Make sure to update to |
Beta Was this translation helpful? Give feedback.
-
Unrelated, to the above, since you're using Mantine DataTable in your project, let me know if you'd be interested in having your logo and a link on the documentation website ;-) |
Beta Was this translation helpful? Give feedback.
-
First off, the new version works like a charm. Thank you for the response and also how fast this was ready! 👏 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello. We use the package for a project of ours and it works great. We recently thought about having the target row open in new tab.
This is doable with something like the onRowClick event and check for ctrlKey, but this does not trigger with middle mouse click.
What are your thoughts on extending the onRowClick to trigger with middle mouse click, or add a new onRowMiddleClick member?
Edit: we are willing to make the pull request, this is just as a feedback / idea exchange thread. :)
Beta Was this translation helpful? Give feedback.
All reactions