Skip to content

Commit 0af8f03

Browse files
Okianailhan007
authored andcommitted
fix(ui5-toast): implement popover api to ensure toast is top level element (#10178)
* fix(ui5-toast): implement popover api to ensure toast is top level element * fix(ui5-toast): implement popover api to ensure toast is top level element add show/hide func of popover api * fix(ui5-toast): implement popover api to ensure toast is top level element * fix(ui5-toast): implement popover api to ensure toast is top level element update lint * fix(ui5-toast): implement popover api to ensure toast is top level element fix lint errors * fix(ui5-toast): implement popover api to ensure toast is top level element * fix(ui5-toast): implement popover api to ensure toast is top level element * fix(ui5-toast): implement popover api to ensure toast is top level element * fix(ui5-toast): implement popover api to ensure toast is top level element Revert html page and fix lint * fix(ui5-toast): remove popover attribute from on enter dom
1 parent 3e4f1f3 commit 0af8f03

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { html } from "lit";
2+
import "../../src/Toast.js";
3+
import "../../src/Button.js";
4+
import "../../src/List.js";
5+
import type Toast from "../../src/Toast.js";
6+
7+
describe("Toast - test popover API", () => {
8+
it("Should verify the toast has the popover attribute set to manual", () => {
9+
cy.mount(html`
10+
<ui5-toast id="toast" open placement="TopStart">TopStart</ui5-toast>`);
11+
cy.get<Toast>("[ui5-toast]")
12+
.should("have.attr", "popover", "manual")
13+
.should("be.visible");
14+
});
15+
16+
it("Toast should stay on top of list after scroll", () => {
17+
cy.mount(html`
18+
<ui5-toast id="toast" open duration="999999" placement="TopStart">TopStart</ui5-toast>
19+
<ui5-list id="list" header-text="List with ListItemStandard" style="opacity: 0.7">
20+
<ui5-li additional-text="3">List Item 1</ui5-li>
21+
<ui5-li additional-text="2">List Item 2</ui5-li>
22+
<ui5-li additional-text="1">List Item 3</ui5-li>
23+
</ui5-list>`);
24+
25+
cy.get<Toast>("[ui5-toast]")
26+
.should("have.attr", "popover", "manual")
27+
.should("be.visible");
28+
29+
cy.get("#toast")
30+
.then($toast => {
31+
const toastRect = $toast[0].getBoundingClientRect();
32+
cy.get("#list")
33+
.then($list => {
34+
const listRect = $list[0].getBoundingClientRect();
35+
const isOverlapping = toastRect.right > listRect.left
36+
&& toastRect.left < listRect.right
37+
&& toastRect.bottom > listRect.top
38+
&& toastRect.top < listRect.bottom;
39+
expect(isOverlapping).to.be.true;
40+
});
41+
});
42+
});
43+
});

packages/main/src/Toast.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,15 @@ class Toast extends UI5Element {
190190
}
191191
}
192192

193+
onAfterRendering() {
194+
if (!this.hasAttribute("popover")) {
195+
this.setAttribute("popover", "manual");
196+
}
197+
if (this.open) {
198+
this.showPopover();
199+
}
200+
}
201+
193202
_onfocusin() {
194203
if (this.focusable) {
195204
this.focused = true;
@@ -217,6 +226,7 @@ class Toast extends UI5Element {
217226
this.focusable = false;
218227
this.focused = false;
219228
this.fireDecoratorEvent("close");
229+
this.hidePopover();
220230
}
221231

222232
_onmouseover() {

packages/main/src/themes/Toast.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
text-overflow: ellipsis;
1818
white-space: pre-line;
1919
padding: 1rem;
20+
inset: unset;
21+
margin: 0;
22+
border: none;
2023
}
2124

2225
.ui5-toast-root {

0 commit comments

Comments
 (0)