Skip to content
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(router): If users are using the Alt key when clicking the router links, prioritize browser’s default behavior #38375

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion goldens/public-api/router/router.d.ts
Expand Up @@ -432,7 +432,7 @@ export declare class RouterLinkWithHref implements OnChanges, OnDestroy {
constructor(router: Router, route: ActivatedRoute, locationStrategy: LocationStrategy);
ngOnChanges(changes: SimpleChanges): any;
ngOnDestroy(): any;
onClick(button: number, ctrlKey: boolean, metaKey: boolean, shiftKey: boolean): boolean;
onClick(button: number, ctrlKey: boolean, shiftKey: boolean, altKey: boolean, metaKey: boolean): boolean;
}

export declare class RouterModule {
Expand Down
9 changes: 6 additions & 3 deletions packages/router/src/directives/router_link.ts
Expand Up @@ -359,9 +359,12 @@ export class RouterLinkWithHref implements OnChanges, OnDestroy {
}

/** @nodoc */
@HostListener('click', ['$event.button', '$event.ctrlKey', '$event.metaKey', '$event.shiftKey'])
onClick(button: number, ctrlKey: boolean, metaKey: boolean, shiftKey: boolean): boolean {
if (button !== 0 || ctrlKey || metaKey || shiftKey) {
@HostListener(
'click',
['$event.button', '$event.ctrlKey', '$event.shiftKey', '$event.altKey', '$event.metaKey'])
onClick(button: number, ctrlKey: boolean, shiftKey: boolean, altKey: boolean, metaKey: boolean):
boolean {
if (button !== 0 || ctrlKey || shiftKey || altKey || metaKey) {
return true;
}

Expand Down