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-popover): avoid dangling aria-labelledby attribute #5428

Merged
merged 2 commits into from
Jun 29, 2022
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
6 changes: 5 additions & 1 deletion packages/main/src/Popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,11 @@ class Popover extends Popup {
}

get _ariaLabelledBy() { // Required by Popup.js
return this._ariaLabel ? undefined : "ui5-popup-header";
if (!this._ariaLabel && this._displayHeader) {
return "ui5-popup-header";
}

return undefined;
}

get _ariaModal() { // Required by Popup.js
Expand Down
6 changes: 6 additions & 0 deletions packages/main/test/specs/Popover.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,4 +353,10 @@ describe("Acc", () => {

assert.strictEqual(await popover.shadow$(".ui5-popup-root").getAttribute("aria-label"), expectedText, "aria-label should be the text of the label.");
});

it("tests that aria-labelledby is not set when there is no header and no accessible-name-ref", async () => {
const popoverWithoutHeader = await browser.$("#popoverAttr");

assert.isNull(await popoverWithoutHeader.shadow$(".ui5-popup-root").getAttribute("aria-labelledby"), "Popover should NOT have aria-labelledby set.");
});
});