Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Fix #8182 by adding a check for left mouse click. #8183

Closed
wants to merge 1 commit into from

Conversation

ryanstewart
Copy link
Contributor

This should fix #8182 . @peterflynn can you double check?

if (_mouseupTimeoutId !== null) {
_mouseupTimeoutId = window.setTimeout(function () {
// if we get a double-click,_mouseupTimeoutId will have been set to lull by the double-click handler before this runs. Also double check to make sure it only happens on left mouse clicks.
if (_mouseupTimeoutId !== null && event.which === 1) {
Copy link

Choose a reason for hiding this comment

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

We should test event.which at the very beginning of the mouseup handler (so we don't do any of this logic if the original click wasn't a left click).

Copy link

Choose a reason for hiding this comment

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

Also, minor nit I just noticed: the comment above says _mouseupTimeoutId will have been set to lull. I think you meant lulz. Er, I mean null. (Also missing a space after the comma.)

@njx
Copy link

njx commented Jun 19, 2014

Yup, it looks like this fixes it. Reviewed with a couple of notes.

@njx njx self-assigned this Jun 19, 2014
@njx njx added this to the Release 0.41 milestone Jun 19, 2014
@redmunds
Copy link
Contributor

FYI, this bug is getting in my way, so I copied this fix locally on Win7. I am now seeing these exceptions in console:

Uncaught TypeError: Cannot read property 'which' of undefined 

Note: I think this happens when I click again before timeout happens.

@marcelgerber
Copy link
Contributor

My fix #8194 worked, but I closed it in favor of this one (Sorry for the dupe).
@ryanstewart You may just take my fix

@njx
Copy link

njx commented Jun 20, 2014

@redmunds Oops, you're right, it looks like it should be event.button as in @SAplayer's fix. I wonder why Ryan's fix worked for me.

@SAplayer I'll look at merging yours in a bit.

@marcelgerber
Copy link
Contributor

Well, both button and which work, but according to StackOverflow (see first comment), button is better defined (because it's specific to MouseEvent).
But this fix won't work because event isn't passed further down.

@njx
Copy link

njx commented Jun 20, 2014

@SAplayer I don't think that's the reason - event is in the outer closure, so it should be available in the nested closure.

It's weird - I can't reproduce @redmunds' exception on Windows. I thought maybe it was a shell version thing, but it doesn't seem to happen for me in any of the versions we've been using.

Anyway, it seems clear that button is better. (I looked in CodeMirror, and it looks like it tests which first, then button, probably because different browsers have historically had different properties for this...)

@njx
Copy link

njx commented Jun 20, 2014

Closing in favor of #8194.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't right-click project tree nodes
4 participants