mathuo / dockview

Zero dependency Docking Layout Manager. Supports Vanilla TypeScript, React and Vue.

Home Page:https://dockview.dev

Repository from Github https://github.commathuo/dockviewRepository from Github https://github.commathuo/dockview

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:

  1. Create a custom tabComponent.
  2. Add behaviour on mouse button different than 0.
  3. 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();}}