-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
fix(angular): routerLink allows opening in a new tab for link elements #25014
Conversation
Co-authored-by: Julian Pfeil <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gave this a shot with dev build 6.0.14-dev.11648653425.149f5ee0
, works great 👍 I'm not sure why we had that preventDefault
either haha. The only thing I could think of was maybe preventing hard refreshes in the page transition due to the href
, but I'm still seeing the nice SPA transition. So yeah, looks good.
@@ -31,19 +37,15 @@ export class RouterLinkDelegateDirective implements OnInit, OnChanges { | |||
this.updateTargetUrlAndHref(); | |||
} | |||
|
|||
@HostListener('click') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need the "@internal" comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies to the user I just tagged by accident 😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe so. I'm unsure why it was marked as @internal
in the first place. Not a convention that exists in the Angular code base for a similar implementation: https://github.com/angular/angular/blob/master/packages/router/src/directives/router_link.ts#L238-L239
Also not a method that developers are accessing through a public API.
I believe this PR has introduced a regression where all Just wanted to give y'all a heads up just in case, since this could affect a bunch of people if they hit the same issue that we did. More info after some sleep. |
Thanks for the heads up. I can reproduce this and will work on a fix. |
@liamdebeasi Awesome, thank you. I won't bother with a repro then :) You are the best as always. |
Mind giving this dev build a test?
Pressing |
This issue is resolved in Ionic 6.0.16. Please update your apps to receive a fix:
|
Pull request checklist
Please check if your PR fulfills the following requirements:
npm run build
) was run locally and any changes were pushednpm run lint
) has passed locally and any fixes were made for failuresPull request type
Please check the type of change your PR introduces:
What is the current behavior?
Users are unable to ctrl/CMD + click on link elements (
<a routerLink="/">
) to open a link in a new tab.Issue URL: #24413
What is the new behavior?
Removes preventing the default behavior on the click event, to re-add support for ctrl/CMD + clicking on a link element to open the URL in a new tab.
Note: Angular's router link directive source code can be found here. There is no behavior that prevents the event, so I am uncertain why we did in the first place.
Does this introduce a breaking change?
Other information
Closing #24440 in favor of this PR (co-authored-by applied to the commit).
Cypress test support for CTRL/CMD + click is pretty tricky/finicky. Opted for not writing tests on this behavior at this time.
If we would like to support this behavior on our Ionic components in the future, we will likely need to render an
a
tag around the element or swap the inner element to ana
tag to support the browser default behaviors.