atom / tabs

Tabs in Atom
MIT License
111 stars 115 forks source link

Fix tab close on middle click for Electron 3 #552

Closed VarNepvius closed 5 years ago

VarNepvius commented 5 years ago

Description of the Problem

When using Atom with Electron 3, a middle click does not close a tab. This happens, because Electron 3 is based on a Chrome version >= 55. Since then, Chrome changed how click events work. Non-primary clicks now fire the event auxclick rather than click.

See https://developers.google.com/web/updates/2016/10/auxclick and https://developer.mozilla.org/en-US/docs/Web/Events/auxclick for more information on the event.

Description of the Change

This PR adds the onClick handler of TabBarView also as listener to the auxclick event.

Alternate Designs

None

Benefits

The change fixes the problem for Electron 3 while it does have no effect in Electron 2, since the auxclick event never fires in this version.

This helps with a future migration of Atom to Electron 3 and fixes the issue for unofficial distributions using Electron 3 now.

Possible Drawbacks

None

Applicable Issues

fixes atom/tabs#545

eli-schwartz commented 5 years ago

One unofficial distribution using electron 3 today is Arch Linux: https://bugs.archlinux.org/task/61047

daviwil commented 5 years ago

Thanks a lot, @VarNepvius! Verified that this fixes the issue on a build of Atom on Electron 3 and it also doesn't have any negative side effects on Atom 1.34.0 stable.