Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui5-li): allow support for anchor tags in ListItem #6126

Merged
merged 3 commits into from
Dec 15, 2022
Merged
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
4 changes: 3 additions & 1 deletion packages/main/src/ListItem.js
Original file line number Diff line number Diff line change
@@ -353,7 +353,9 @@ class ListItem extends ListItemBase {
return;
}

event.preventDefault();
if (isEnter(event)) {
event.preventDefault();
}
this.fireEvent("_press", { item: this, selected: this.selected, key: event.key });
}

7 changes: 7 additions & 0 deletions packages/main/test/pages/List_test_page.html
Original file line number Diff line number Diff line change
@@ -237,6 +237,13 @@ <h2 id="testHeader">Test aria</h2>
<ui5-li>DVD set</ui5-li>
</ui5-list>

<ui5-list id="listWithAnchorTag">
<ui5-li>
<a id="linkInListItem" tabindex="-1" href="https://sap.github.io/ui5-webcomponents/playground/components" rel="noopener" target="_self">
Link1</a>
</ui5-li>
</ui5-list>

<script>
'use strict';

10 changes: 10 additions & 0 deletions packages/main/test/specs/List.spec.js
Original file line number Diff line number Diff line change
@@ -480,4 +480,14 @@ describe("List Tests", () => {

assert.strictEqual(await groupHeader.getAttribute("role"), "group", "Item label is empty");
});

it('anchor tabs should be accessible within list items', async () => {
const listItem = await browser.$("#linkInListItem");

await listItem.click();
const url = await browser.getUrl();
assert.strictEqual(url, "https://sap.github.io/ui5-webcomponents/playground/components", "Link target is accessible");

await browser.url(`test/pages/List_test_page.html`);
});
});