Skip to content

Commit

Permalink
fix(ui5-popover): fix finding opener (#10360)
Browse files Browse the repository at this point in the history
* fix(ui5-popover): fix finding opener

* chore(ui5-popover): add tests
  • Loading branch information
TeodorTaushanov authored Dec 13, 2024
1 parent fe8d224 commit 941c6eb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/main/src/Popover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ class Popover extends Popup {
}

if (openerHTMLElement && this._isUI5Element(openerHTMLElement)) {
return openerHTMLElement.getFocusDomRef();
return openerHTMLElement.getFocusDomRef() || openerHTMLElement;
}

return openerHTMLElement;
Expand Down
10 changes: 10 additions & 0 deletions packages/main/test/pages/PopoverInitiallyOpen.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,15 @@
</head>
<body onload="init()">
<ui5-button id="btn1">Open Popover</ui5-button>

<ui5-button id="openPopoverBtn1">Open Popover</ui5-button>
<ui5-popover id="popover1" opener="openPopoverBtn1" open>Content</ui5-popover>

<br />
<br />
<br />

<ui5-button id="openPopoverBtn2">Open Popover</ui5-button>
<ui5-popover id="popover2" open opener="openPopoverBtn2">Content</ui5-popover>
</body>
</html>
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 @@ -475,6 +475,12 @@ describe("Initially opened", () => {
it("test initial focus", async () => {
assert.ok(await browser.$("#popoverBtn").matches(":focus"), "initial focus is correct");
});

it("test _open", async () => {
assert.ok(await browser.$("#popoverOpen")._open, "_open is set");
assert.ok(await browser.$("#popover1")._open, "_open is set");
assert.ok(await browser.$("#popover2")._open, "_open is set");
});
});

describe("Acc", () => {
Expand Down

0 comments on commit 941c6eb

Please sign in to comment.