Cannot close tab with middle mouse button
nicolasventer opened this issue · comments
Describe the bug
I cannot override the Default Tab Component to close it with Middle mouse button.
To Reproduce
Here is a sandbox: https://codesandbox.io/p/sandbox/suspicious-wescoff-c3vdvy?workspaceId=ws_79FcfY23253R5ftVLTeEds
Here is the tab component:
closeWithMiddleClick: (props: IDockviewPanelHeaderProps) => (
<DockviewDefaultTab
onClick={(ev) => {
console.log("ev.button:", ev.button);
if (ev.button === 1) props.api.close();
}}
{...props}
/>
),
Steps to reproduce the behavior:
- Create a custom tabComponent.
- Add behaviour on mouse button different than 0.
- Try to interact and you can see only the left click is handled.
Expected behavior
It is expected to control the behaviour on click of tab with other button than left click.
Can you please take a look at this issue ?
Thanks
Additional request
I think it should be a good idea to add this behaviour in parameters of the Default Tab component.
And to go even further, I think it should be even better if it was the default behaviour of Tab.
(This is the case in VS Code, or MS Edge, and many other software with tabs.)
I was able to workaround it by using onAuxClick
event
onAuxClick={(e) => { if (e.button === 1) p.api.close();}}