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

Do not activate push state links if meta or shift are clicked. #335

Merged
merged 1 commit into from
Mar 13, 2014
Merged

Do not activate push state links if meta or shift are clicked. #335

merged 1 commit into from
Mar 13, 2014

Conversation

nhunzaker
Copy link
Contributor

When using the {{#link}} handlebars helper, right clicks and clicks using meta/shift keys do not follow traditional browser behavior. I took a look at how AirBnB's Rendr is handling this, and placed similar checks in the _anchorClicked view method.

Unfortunately, my change isn't quite as robust as I would like. Right clicking still triggers pushState, and I cant ctrl+click on OSX to utilize the context menu, however it at least gets things to the point where I can open up links in a new window/tab if so desired.

@eastridge
Copy link
Contributor

@nhunzaker do you know why pushState still triggers if you are returning?

@nhunzaker
Copy link
Contributor Author

I'm not sure. The most direct solution is to cancel if event.which === 3, but that's lame. I made a quick test to confirm that right click does not trigger click events. I'll do some more research when I have a free moment.

@nhunzaker
Copy link
Contributor Author

Okay! It looks like right clicks behave as expected in IE, Chrome, and Safari. This is clearly an issue in Firefox however it works as expected in the test I mentioned earlier. I'm going to see if there's something else happening before the click event reaches this function.

Alternatively, event.which === 3 works flawlessly, but adds another moving part, which I'm generally against.

@nhunzaker
Copy link
Contributor Author

Well this is embarrassing. It looks like this is an issue with my OSX magic trackpad. When I use a standard mouse, or change methods of right clicking (like tapping with two touches) there isn't an issue whatsoever.

event.which === 3 doesn't handle this case, because the event actually registers 1 as the button pressed.

Do you think this is good to go?

@eastridge
Copy link
Contributor

@kpdecker, this looks good to me, any potential side effects you see?

On Wed, Mar 12, 2014 at 6:33 AM, Nathan Hunzaker
[email protected]:

Well this is embarrassing. It looks like this is an issue with my OSX
magic trackpad. When I use a standard mouse, or change methods of right
clicking (like tapping with two touches) there isn't an issue whatsoever.

event.which === 3 doesn't handle this case, because the event actually
registers 1 as the button pressed.

Do you think this is good to go?

Reply to this email directly or view it on GitHubhttps://github.com//pull/335#issuecomment-37408107
.

kpdecker added a commit that referenced this pull request Mar 13, 2014
Do not activate push state links if meta or shift are clicked.
@kpdecker kpdecker merged commit 532c75c into walmartlabs:master Mar 13, 2014
@kpdecker
Copy link
Contributor

kpdecker commented Apr 1, 2014

Released in v3.0.0-alpha.1

@jacobsvante
Copy link
Contributor

Do you plan to backport any of these fixes to v2?

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

Successfully merging this pull request may close these issues.

4 participants