Skip to content

Commit cce6ca8

Browse files
niyapilhan007
authored andcommitted
fix(ui5-toast): Content is announced when ui5-toast is shown (#3939)
1 parent 276b142 commit cce6ca8

File tree

3 files changed

+48
-11
lines changed

3 files changed

+48
-11
lines changed

packages/main/src/Toast.hbs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
<div class="ui5-toast-root"
2-
role="alert"
3-
style="{{styles.root}}"
4-
dir="{{effectiveDir}}"
5-
@mouseover="{{_onmouseover}}"
6-
@mouseleave="{{_onmouseleave}}"
7-
@transitionend="{{_ontransitionend}}">
8-
<bdi>
9-
<slot></slot>
10-
</bdi>
11-
</div>
1+
{{#if domRendered}}
2+
<div class="ui5-toast-root"
3+
role="alert"
4+
style="{{styles.root}}"
5+
dir="{{effectiveDir}}"
6+
@mouseover="{{_onmouseover}}"
7+
@mouseleave="{{_onmouseleave}}"
8+
@transitionend="{{_ontransitionend}}">
9+
<bdi>
10+
<slot></slot>
11+
</bdi>
12+
</div>
13+
{{/if}}

packages/main/src/Toast.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,15 @@ const metadata = {
7979
hover: {
8080
type: Boolean,
8181
},
82+
83+
/**
84+
* Indicates whether the component DOM is rendered.
85+
* @type {boolean}
86+
* @private
87+
*/
88+
domRendered: {
89+
type: Boolean,
90+
},
8291
},
8392
slots: /** @lends sap.ui.webcomponents.main.Toast.prototype */ {
8493
/**
@@ -206,6 +215,7 @@ class Toast extends UI5Element {
206215
}
207216

208217
_initiateOpening() {
218+
this.domRendered = true;
209219
requestAnimationFrame(_ => {
210220
this.open = true;
211221
});
@@ -215,6 +225,7 @@ class Toast extends UI5Element {
215225
if (this.hover) {
216226
return;
217227
}
228+
this.domRendered = false;
218229
this.open = false;
219230
}
220231

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,25 @@ describe("Toast general interaction", () => {
2424
"Toast's content div should be displayed in the viewport after its opening.")
2525
});
2626

27+
it("tests domRendered property", () => {
28+
const button = browser.$("#wcBtnShowToastBS");
29+
const toast = browser.$("#wcToastBS");
30+
const toastShadowContent = toast.shadow$(".ui5-toast-root");
31+
32+
assert.notOk(toastShadowContent.isDisplayedInViewport(),
33+
"Toast's content div should be displayed in the viewport after its opening.");
34+
assert.notOk(toast.getProperty("domRendered"),
35+
"domRendered property value should be false before Toast is shown");
36+
37+
button.click();
38+
39+
assert.strictEqual(toast.getProperty("domRendered"), true,
40+
"domRendered property value should be true when Toast is shown");
41+
42+
assert.ok(toastShadowContent.isDisplayedInViewport(),
43+
"Toast's content div should be displayed in the viewport after its opening.")
44+
});
45+
2746
it("tests duration property", () => {
2847
const button = browser.$("#wcBtnShowToastTC");
2948
const toast = browser.$("#wcToastTC");
@@ -45,8 +64,11 @@ describe("Toast general interaction", () => {
4564
});
4665

4766
it("tests shadow content div role", () => {
67+
const button = browser.$("#wcBtnShowToastBE");
4868
const toastShadowContent = browser.$("#wcToastBE").shadow$(".ui5-toast-root");
4969

70+
button.click();
71+
5072
assert.strictEqual(toastShadowContent.getAttribute("role"), "alert",
5173
"The role of the shadow ui5-toast-root div should be alert");
5274
});
@@ -111,6 +133,8 @@ describe("Toast general interaction", () => {
111133

112134
assert.notOk(toast.getProperty("open"),
113135
"Open property should be false after Toast is closed");
136+
assert.notOk(toast.getProperty("domRendered"),
137+
"domRendered property value should be false after Toast is closed");
114138
});
115139

116140
it("tests minimum allowed duration", () => {

0 commit comments

Comments
 (0)