-
Notifications
You must be signed in to change notification settings - Fork 12
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
Handle Cmd / Ctrl click to open in a new tab #6
Comments
@buschtoens In our app we mimicked this code in https://github.com/intercom/ember-href-to/blob/master/addon/href-to.js#L35-L39
|
Thanks for the link, @rtablada! 😊 |
There's also the possibility of Cmd or Ctrl clicking a button, which would open the form submission in a new tab. Contrary to It's probably easiest to understand, if I don't expose yet another flag and instead just bake all of this (including |
Released in https://github.com/buschtoens/ember-link/releases/tag/v1.2.1. 🥳 |
When a link is clicked with Cmd / Ctrl it should open in a new tab.
The reason it does not work right now is that we always call
event.preventDefault()
, if@preventDefault
istrue
/ unset.I think there's different solutions to this.
For one, we can add another boolean:
@allowNewTab
If
true
(default) it will check whetherevent.currentTarget
is an<a>
element and if Cmd / Ctrl are pressed, in which case it will not callevent.preventDefault()
, even if@preventDefault
istrue
.In addition to this, we can also add another action
openInNewTab
, that openshref
in a new tab.Big thanks to @tchak13, who reported this via Twitter:
https://twitter.com/tchak13/status/1106149903317852160
The text was updated successfully, but these errors were encountered: