-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ui5-popover): allow setting
opener
to an abstract element DOM r…
…eference (#10419) When Popover's opener is set as a DOM reference and if happens to be a UI5 Element, we need to return its DOM (focus) reference. As of now we just return the element itself. While this works for most of the cases, it does not work for abstract elements as the popover won't be able to calculate its position due to not having a physically DOM element as opener. The case when the opener is set as string, ID, pointing to an element has been already handled. For this case we already call getFocusDomRef. And, this change addresses the other case - setting the opener as DOM reference.
- Loading branch information
Showing
6 changed files
with
97 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { html } from "lit"; | ||
import "../../src/Button.js"; | ||
import "../../src/Toolbar.js"; | ||
import "../../src/ToolbarButton.js"; | ||
import "../../src/Popover.js"; | ||
|
||
describe("Popover opener", () => { | ||
it("tests 'opener' set as string of abstract element's ID ", () => { | ||
cy.mount(html` | ||
<ui5-toolbar id="tb"> | ||
<ui5-toolbar-button text="Add"></ui5-toolbar-button> | ||
<ui5-toolbar-button text="Delete" id="clearCounter"></ui5-toolbar-button> | ||
<ui5-toolbar-button id="btnOpenMenu" text="Open Menu" prevent-overflow-closing></ui5-toolbar-button> | ||
</ui5-toolbar> | ||
<ui5-popover id="popup" opener="btnOpenMenu"> | ||
<ui5-button id="btnClosePopover">Close</ui5-button> | ||
</ui5-popover> | ||
`); | ||
|
||
// act | ||
cy.get("#popup").invoke("prop", "open", "true"); | ||
|
||
// assert - The button inside the popover is accessible => popover is opened properly. | ||
cy.get("#btnClosePopover").then($btnClosePopover => { | ||
$btnClosePopover.get(0).addEventListener("click", () => { | ||
cy.get("#popup").invoke("prop", "open", false); | ||
}); | ||
}); | ||
cy.get("#btnClosePopover").realClick(); | ||
}); | ||
|
||
it("tests 'opener' set as DOM ref of abstract element's DOM reference", () => { | ||
cy.mount(html` | ||
<ui5-toolbar id="tb"> | ||
<ui5-toolbar-button text="Add"></ui5-toolbar-button> | ||
<ui5-toolbar-button text="Delete"></ui5-toolbar-button> | ||
<ui5-toolbar-button id="btnOpenPopover" text="Open Menu" prevent-overflow-closing></ui5-toolbar-button> | ||
</ui5-toolbar> | ||
<ui5-popover id="popup"> | ||
<ui5-button id="btnClosePopover">Close</ui5-button> | ||
</ui5-popover> | ||
`); | ||
|
||
cy.get("#btnOpenPopover").then($toolbarBtn => { | ||
cy.wrap($toolbarBtn.get(0)).as("toolbarBtn"); | ||
}); | ||
|
||
// act | ||
cy.get("@toolbarBtn").then($toolbarBtn => { | ||
cy.get("#popup").invoke("prop", "opener", $toolbarBtn.get(0)); | ||
}); | ||
cy.get("#popup").invoke("prop", "open", true); | ||
|
||
// assert - The button inside the popover is accessible => popover is opened properly. | ||
cy.get("#btnClosePopover").then($btnClosePopover => { | ||
$btnClosePopover.get(0).addEventListener("click", () => { | ||
cy.get("#popup").invoke("prop", "open", false); | ||
}); | ||
}); | ||
cy.get("#btnClosePopover").realClick(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters