From 4c32cb952f51a19748bf43715b931e109ef2a15c Mon Sep 17 00:00:00 2001 From: Robert Spier Date: Thu, 25 May 2017 17:52:55 -0700 Subject: [PATCH] fix(router): opening links in new window Shift-clicks on router-links should not prevent browser default action. A follow on to: https://github.com/angular/angular/commit/1ac9dda93d01e5e61a3af32a9c596e6f26d50b00 --- packages/router/src/directives/router_link.ts | 6 +++--- tools/public_api_guard/router/router.d.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/router/src/directives/router_link.ts b/packages/router/src/directives/router_link.ts index 7c3dd56fe8..0b011c0907 100644 --- a/packages/router/src/directives/router_link.ts +++ b/packages/router/src/directives/router_link.ts @@ -209,9 +209,9 @@ export class RouterLinkWithHref implements OnChanges, OnDestroy { ngOnChanges(changes: {}): any { this.updateTargetUrlAndHref(); } ngOnDestroy(): any { this.subscription.unsubscribe(); } - @HostListener('click', ['$event.button', '$event.ctrlKey', '$event.metaKey']) - onClick(button: number, ctrlKey: boolean, metaKey: boolean): boolean { - if (button !== 0 || ctrlKey || metaKey) { + @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) { return true; } diff --git a/tools/public_api_guard/router/router.d.ts b/tools/public_api_guard/router/router.d.ts index be4cac7112..78daa31a96 100644 --- a/tools/public_api_guard/router/router.d.ts +++ b/tools/public_api_guard/router/router.d.ts @@ -337,7 +337,7 @@ export declare class RouterLinkWithHref implements OnChanges, OnDestroy { constructor(router: Router, route: ActivatedRoute, locationStrategy: LocationStrategy); ngOnChanges(changes: {}): any; ngOnDestroy(): any; - onClick(button: number, ctrlKey: boolean, metaKey: boolean): boolean; + onClick(button: number, ctrlKey: boolean, metaKey: boolean, shiftKey: boolean): boolean; } /** @stable */