Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 0 additions & 61 deletions packages/main/cypress/specs/Link.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -260,65 +260,4 @@ describe("General API", () => {
cy.get("@signInDialog")
.should("be.visible");
});

it("tabindex should update when text content is added after mount", () => {
// Mount link without text content
cy.mount(<Link id="dynamic-link"></Link>);

// Initially, tabindex should be -1 because there's no text content
cy.get("#dynamic-link")
.shadow()
.find(".ui5-link-root")
.should("have.attr", "tabindex", "-1");

// Add text content dynamically
cy.get("#dynamic-link")
.then($link => {
$link[0].textContent = "Click me";
});

// After text is added, tabindex should become 0
cy.get("#dynamic-link")
.shadow()
.find(".ui5-link-root")
.should("have.attr", "tabindex", "0");
});

it("tabindex should remain 0 when text content changes", () => {
cy.mount(<Link id="text-change-link">Initial Text</Link>);

cy.get("#text-change-link")
.shadow()
.find(".ui5-link-root")
.should("have.attr", "tabindex", "0");

cy.get("#text-change-link")
.then($link => {
$link[0].textContent = "Updated Text";
});

cy.get("#text-change-link")
.shadow()
.find(".ui5-link-root")
.should("have.attr", "tabindex", "0");
});

it("tabindex should be -1 when text content is removed", () => {
cy.mount(<Link id="remove-text-link">Some text</Link>);

cy.get("#remove-text-link")
.shadow()
.find(".ui5-link-root")
.should("have.attr", "tabindex", "0");

cy.get("#remove-text-link")
.then($link => {
$link[0].textContent = "";
});

cy.get("#remove-text-link")
.shadow()
.find(".ui5-link-root")
.should("have.attr", "tabindex", "-1");
});
});
12 changes: 1 addition & 11 deletions packages/main/src/Link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
import event from "@ui5/webcomponents-base/dist/decorators/event-strict.js";
import property from "@ui5/webcomponents-base/dist/decorators/property.js";
import slot from "@ui5/webcomponents-base/dist/decorators/slot.js";
import jsxRenderer from "@ui5/webcomponents-base/dist/renderer/JsxRenderer.js";
import type { AccessibilityAttributes } from "@ui5/webcomponents-base/dist/types.js";
import { isSpace, isEnter } from "@ui5/webcomponents-base/dist/Keys.js";
Expand Down Expand Up @@ -269,15 +268,6 @@ class Link extends UI5Element implements ITabbable {
@property()
endIcon?: string;

/**
* Defines the text of the component.
*
* **Note:** Although this slot accepts HTML Elements, it is strongly recommended that you only use text in order to preserve the intended design.
* @public
*/
@slot({ type: Node, "default": true })
text!: Array<Node>;

@property({ noAttribute: true })
_rel: string | undefined;

Expand Down Expand Up @@ -321,7 +311,7 @@ class Link extends UI5Element implements ITabbable {
return Number.parseInt(this.forcedTabIndex);
}

return (this.disabled || !this.textContent?.length) ? -1 : 0;
return this.disabled ? -1 : 0;
}

get ariaLabelText() {
Expand Down
Loading