Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot close tab with middle mouse button #830

Open
nicolasventer opened this issue Jan 19, 2025 · 1 comment · May be fixed by #847
Open

Cannot close tab with middle mouse button #830

nicolasventer opened this issue Jan 19, 2025 · 1 comment · May be fixed by #847

Comments

@nicolasventer
Copy link

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.)

@Morcatko
Copy link

I was able to workaround it by using onAuxClick event

onAuxClick={(e) => { if (e.button === 1) p.api.close();}} 

@mathuo mathuo linked a pull request Jan 30, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants