From 9d05f4372f675267ba7adcf97e4a4d74786a4587 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 19 Oct 2025 20:57:10 +0000 Subject: [PATCH 1/4] Initial plan From f8fca33b6930782ffc2b02fb340e7836c5c819ea Mon Sep 17 00:00:00 2001 From: Maaz Tajammul Date: Mon, 20 Oct 2025 02:13:35 +0500 Subject: [PATCH 2/4] Enhance InertiaLinkDirective with click event handling --- .../src/app/inertia/inertia-link.directive.ts | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/resources/angular/src/app/inertia/inertia-link.directive.ts b/resources/angular/src/app/inertia/inertia-link.directive.ts index 13e5592..d72ebbf 100644 --- a/resources/angular/src/app/inertia/inertia-link.directive.ts +++ b/resources/angular/src/app/inertia/inertia-link.directive.ts @@ -1,4 +1,4 @@ -import { Directive, HostListener, Input } from '@angular/core'; +import { Directive, HostListener, Input, ElementRef } from '@angular/core'; import { router } from "@inertiajs/core"; @Directive({ @@ -8,7 +8,29 @@ export class InertiaLinkDirective { @Input('inertiaLink') href = ''; - @HostListener('click') onClick() { - router.get(this.href); + constructor(private el: ElementRef) {} + + @HostListener('click', ['$event']) + onClick(event: MouseEvent) { + // Only handle primary (usually left) button + if (event.button !== 0) { + return; + } + + // Respect modifier keys so users can open in new tab/window + if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) { + return; + } + + // If no explicit href input, try to read from host element (e.g. ) + const href = this.href || (this.el.nativeElement.getAttribute && this.el.nativeElement.getAttribute('href')) || ''; + + if (!href) { + return; + } + + // Prevent native navigation and use Inertia router + event.preventDefault(); + router.get(href); } } From 9329f2f31a5a80b6ef9d167fce54e3735c9ac40c Mon Sep 17 00:00:00 2001 From: Maaz Tajammul Date: Mon, 20 Oct 2025 13:04:04 +0500 Subject: [PATCH 3/4] Ensure reflect-metadata is loaded before decorators are evaluated. --- resources/angular/src/main.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/resources/angular/src/main.ts b/resources/angular/src/main.ts index c58dc05..cfc64b4 100644 --- a/resources/angular/src/main.ts +++ b/resources/angular/src/main.ts @@ -1,3 +1,6 @@ +// Ensure reflect-metadata is loaded before decorators are evaluated. +import 'reflect-metadata'; + import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { AppModule } from './app/app.module'; From 2c41f5bca34042eaee0c17f3509e5852fe308d79 Mon Sep 17 00:00:00 2001 From: Maaz Tajammul Date: Mon, 20 Oct 2025 13:09:05 +0500 Subject: [PATCH 4/4] Change INERTIA_PAGES token type to array --- resources/angular/src/app/inertia/entities.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/angular/src/app/inertia/entities.ts b/resources/angular/src/app/inertia/entities.ts index b387eb9..b1b897a 100644 --- a/resources/angular/src/app/inertia/entities.ts +++ b/resources/angular/src/app/inertia/entities.ts @@ -1,6 +1,6 @@ import { InjectionToken, Type } from '@angular/core'; -export const INERTIA_PAGES = new InjectionToken('INERTIA_PAGES'); +export const INERTIA_PAGES = new InjectionToken('INERTIA_PAGES'); export enum InertiaMetadata { component = 'inertia:component'