Skip to content

Commit 21d5457

Browse files
authored
fix(ui5-popover): avoid dangling aria-labelledby attribute (#5428)
Part of #3956
1 parent 17465e3 commit 21d5457

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

packages/main/src/Popover.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,11 @@ class Popover extends Popup {
778778
}
779779

780780
get _ariaLabelledBy() { // Required by Popup.js
781-
return this._ariaLabel ? undefined : "ui5-popup-header";
781+
if (!this._ariaLabel && this._displayHeader) {
782+
return "ui5-popup-header";
783+
}
784+
785+
return undefined;
782786
}
783787

784788
get _ariaModal() { // Required by Popup.js

packages/main/test/specs/Popover.spec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,4 +353,10 @@ describe("Acc", () => {
353353

354354
assert.strictEqual(await popover.shadow$(".ui5-popup-root").getAttribute("aria-label"), expectedText, "aria-label should be the text of the label.");
355355
});
356+
357+
it("tests that aria-labelledby is not set when there is no header and no accessible-name-ref", async () => {
358+
const popoverWithoutHeader = await browser.$("#popoverAttr");
359+
360+
assert.isNull(await popoverWithoutHeader.shadow$(".ui5-popup-root").getAttribute("aria-labelledby"), "Popover should NOT have aria-labelledby set.");
361+
});
356362
});

0 commit comments

Comments
 (0)