From 589e606884f00183da4fd9affa5a61a081086fc9 Mon Sep 17 00:00:00 2001 From: tsanislavgatev Date: Thu, 19 Feb 2026 16:14:09 +0200 Subject: [PATCH] fix(ui5-link): open new page in correct tab --- packages/main/cypress/specs/Link.cy.tsx | 10 ++++++++++ packages/main/src/Link.ts | 2 +- packages/main/test/pages/Link.html | 5 +++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/main/cypress/specs/Link.cy.tsx b/packages/main/cypress/specs/Link.cy.tsx index cc4812e79673..a3b826f94db4 100644 --- a/packages/main/cypress/specs/Link.cy.tsx +++ b/packages/main/cypress/specs/Link.cy.tsx @@ -22,6 +22,16 @@ describe("General API", () => { .should("have.attr", "rel", "noreferrer noopener"); }); + it("should not add rel attribute for custom target", () => { + cy.mount(); + + cy.get("[ui5-link]") + .shadow() + .find(".ui5-link-root") + .should("have.attr", "target", "my-target") + .and("not.have.attr", "rel"); + }); + it("should wrap the text of the link", () => { cy.mount( <> diff --git a/packages/main/src/Link.ts b/packages/main/src/Link.ts index f59d9d220fbf..7b11102b6682 100644 --- a/packages/main/src/Link.ts +++ b/packages/main/src/Link.ts @@ -291,7 +291,7 @@ class Link extends UI5Element implements ITabbable { } onBeforeRendering() { - const needsNoReferrer = this.target !== "_self" + const needsNoReferrer = this.target === "_blank" && this.href && this._isCrossOrigin(this.href); diff --git a/packages/main/test/pages/Link.html b/packages/main/test/pages/Link.html index 1bf22d3c9536..24ad35d639b6 100644 --- a/packages/main/test/pages/Link.html +++ b/packages/main/test/pages/Link.html @@ -47,6 +47,11 @@

prevent-default

link click default preventednative span +
+

Custom target

+ Custom target link (click multiple times - should reuse same tab) +
+

overstyle-link

link with different colornative span