Skip to content

Commit e2f530c

Browse files
fix(ui5-link): remove length check from tabindex calculation (#12870)
1 parent 73753f6 commit e2f530c

2 files changed

Lines changed: 1 addition & 72 deletions

File tree

packages/main/cypress/specs/Link.cy.tsx

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -260,65 +260,4 @@ describe("General API", () => {
260260
cy.get("@signInDialog")
261261
.should("be.visible");
262262
});
263-
264-
it("tabindex should update when text content is added after mount", () => {
265-
// Mount link without text content
266-
cy.mount(<Link id="dynamic-link"></Link>);
267-
268-
// Initially, tabindex should be -1 because there's no text content
269-
cy.get("#dynamic-link")
270-
.shadow()
271-
.find(".ui5-link-root")
272-
.should("have.attr", "tabindex", "-1");
273-
274-
// Add text content dynamically
275-
cy.get("#dynamic-link")
276-
.then($link => {
277-
$link[0].textContent = "Click me";
278-
});
279-
280-
// After text is added, tabindex should become 0
281-
cy.get("#dynamic-link")
282-
.shadow()
283-
.find(".ui5-link-root")
284-
.should("have.attr", "tabindex", "0");
285-
});
286-
287-
it("tabindex should remain 0 when text content changes", () => {
288-
cy.mount(<Link id="text-change-link">Initial Text</Link>);
289-
290-
cy.get("#text-change-link")
291-
.shadow()
292-
.find(".ui5-link-root")
293-
.should("have.attr", "tabindex", "0");
294-
295-
cy.get("#text-change-link")
296-
.then($link => {
297-
$link[0].textContent = "Updated Text";
298-
});
299-
300-
cy.get("#text-change-link")
301-
.shadow()
302-
.find(".ui5-link-root")
303-
.should("have.attr", "tabindex", "0");
304-
});
305-
306-
it("tabindex should be -1 when text content is removed", () => {
307-
cy.mount(<Link id="remove-text-link">Some text</Link>);
308-
309-
cy.get("#remove-text-link")
310-
.shadow()
311-
.find(".ui5-link-root")
312-
.should("have.attr", "tabindex", "0");
313-
314-
cy.get("#remove-text-link")
315-
.then($link => {
316-
$link[0].textContent = "";
317-
});
318-
319-
cy.get("#remove-text-link")
320-
.shadow()
321-
.find(".ui5-link-root")
322-
.should("have.attr", "tabindex", "-1");
323-
});
324263
});

packages/main/src/Link.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
22
import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
33
import event from "@ui5/webcomponents-base/dist/decorators/event-strict.js";
44
import property from "@ui5/webcomponents-base/dist/decorators/property.js";
5-
import slot from "@ui5/webcomponents-base/dist/decorators/slot.js";
65
import jsxRenderer from "@ui5/webcomponents-base/dist/renderer/JsxRenderer.js";
76
import type { AccessibilityAttributes } from "@ui5/webcomponents-base/dist/types.js";
87
import { isSpace, isEnter } from "@ui5/webcomponents-base/dist/Keys.js";
@@ -269,15 +268,6 @@ class Link extends UI5Element implements ITabbable {
269268
@property()
270269
endIcon?: string;
271270

272-
/**
273-
* Defines the text of the component.
274-
*
275-
* **Note:** Although this slot accepts HTML Elements, it is strongly recommended that you only use text in order to preserve the intended design.
276-
* @public
277-
*/
278-
@slot({ type: Node, "default": true })
279-
text!: Array<Node>;
280-
281271
@property({ noAttribute: true })
282272
_rel: string | undefined;
283273

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

324-
return (this.disabled || !this.textContent?.length) ? -1 : 0;
314+
return this.disabled ? -1 : 0;
325315
}
326316

327317
get ariaLabelText() {

0 commit comments

Comments
 (0)