Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Fix regression re: closing tabs via middle mouse click on Linux #15183

Merged
merged 4 commits into from
Aug 7, 2017

Conversation

jasonrudolph
Copy link
Contributor

@jasonrudolph jasonrudolph commented Aug 7, 2017

Fixes atom/tabs#461
Fixes atom/tabs#52


On Linux, when the user performs a middle-button mouse click, Chromium fires both a mousedown event and a paste event. This PR teaches the TextEditorComponent to ignore the paste event.

When the user performs a middle-mouse click on a tab, we first get the mousedown event. In response to that event, we close the tab and attempt to prevent Chromium's default processing for the event. This prevents Chromium's default processing for the mousedown event, but then Chromium also fires a paste event, and that event pastes the clipboard's current content into the newly-focused text editor. 🤦

#14987 removed some of the middle-button mouse click handling related to pasting on Linux. This PR restores that logic and the related tests. (See TextEditorComponent::didMouseDownOnContent(event).) With that change in place, since Atom already has its own logic for handling pasting, we shouldn't need to handle browser paste events. By ignoring the browser paste events on Linux, this PR fixes atom/tabs#461.

TODO

Test plan

On Linux, when the user performs a middle-button mouse click, Chromium
fires both a mouse-down event *and* a paste event. This commit teaches
the TextEditorComponent to ignore the paste event.

When the user performs a middle-mouse click on a tab, we get close the
tab and attempt to prevent Chromium's default processing for the event.
[1] This prevents Chromium's default processing for the *mouse down*
event, but then Chromium also fires a *paste* event, and that event
pastes the clipboard's current content into the newly-focused text
editor. 🙀

Since Atom already has its own logic for handling pasting, we
shouldn't (🤞) need to handle browser paste events. By ignoring the
browser paste events on Linux, we fix atom/tabs#461.

[1]
https://github.com/atom/tabs/blob/ce1d92e0abb669155caa178bb71166b9f16f329a/lib/tab-bar-view.coffee#L416-L418
@@ -1549,6 +1551,11 @@ class TextEditorComponent {
}
}

didPaste (event) {
// TODO Explain the motivation for this logic
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll resolve this TODO before merging this PR.

@alexandernst
Copy link

Wasn't that fixed some weeks ago?

@ungb
Copy link
Contributor

ungb commented Aug 7, 2017

@alexandernst, the fix that went in 2 weeks ago was regarding middle clicking pasting twice(#14987) which is a different issue than Closing tab with middle mouse pastes in next tab(atom/tabs#461)

@jasonrudolph
Copy link
Contributor Author

@ungb: I think this is ready to 🚀. Wanna take it for a spin before I merge?

@jasonrudolph
Copy link
Contributor Author

/fyi @nathansobo: Just a courtesy ping in case you're interested in reviewing this PR. If so, I certainly welcome it, but please don't feel obligated. 🙇

@jasonrudolph jasonrudolph merged commit c850f38 into master Aug 7, 2017
@jasonrudolph jasonrudolph deleted the jr-is-there-anything-a-middle-click-CANT-do branch August 7, 2017 17:24
jasonrudolph added a commit that referenced this pull request Aug 7, 2017
…ck-CANT-do

Fix regression re: closing tabs via middle mouse click on Linux
jasonrudolph added a commit that referenced this pull request Aug 7, 2017
…ck-CANT-do

Fix regression re: closing tabs via middle mouse click on Linux
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants