From c46a8402f6fc1735ae3ac9cb19c93b0f5987240a Mon Sep 17 00:00:00 2001 From: Petar Dimov Date: Thu, 11 Nov 2021 18:35:15 +0200 Subject: [PATCH] fix(ui5-busy-indicator): Improve delay handling - Don't render focusable elements until the delay has passed - Don't reduce the opacity and prevent actions of the slotted elements until the delay has passed Fixes: #4108 --- packages/main/src/BusyIndicator.hbs | 2 +- packages/main/src/BusyIndicator.js | 7 +++---- packages/main/src/themes/BusyIndicator.css | 6 +++--- packages/main/test/pages/BusyIndicator.html | 19 +++++++++++++++++++ .../main/test/specs/BusyIndicator.spec.js | 17 ++++++++++++++++- 5 files changed, 42 insertions(+), 9 deletions(-) diff --git a/packages/main/src/BusyIndicator.hbs b/packages/main/src/BusyIndicator.hbs index 9149805cd618..7e22f3a8b23e 100644 --- a/packages/main/src/BusyIndicator.hbs +++ b/packages/main/src/BusyIndicator.hbs @@ -26,7 +26,7 @@ - {{#if active}} + {{#if _isBusy}} {{/if}} \ No newline at end of file diff --git a/packages/main/src/BusyIndicator.js b/packages/main/src/BusyIndicator.js index 3cffccd3bcda..362588bd3539 100644 --- a/packages/main/src/BusyIndicator.js +++ b/packages/main/src/BusyIndicator.js @@ -97,8 +97,7 @@ const metadata = { * @private */ _isBusy: { - type: Boolean, - noAttribute: true, + type: Boolean }, }, }; @@ -231,7 +230,7 @@ class BusyIndicator extends UI5Element { } _handleKeydown(event) { - if (!this.active) { + if (!this._isBusy) { return; } @@ -246,7 +245,7 @@ class BusyIndicator extends UI5Element { } _preventEvent(event) { - if (this.active) { + if (this._isBusy) { event.stopImmediatePropagation(); } } diff --git a/packages/main/src/themes/BusyIndicator.css b/packages/main/src/themes/BusyIndicator.css index 8cf84a50cf41..254d6fbad5d6 100644 --- a/packages/main/src/themes/BusyIndicator.css +++ b/packages/main/src/themes/BusyIndicator.css @@ -2,18 +2,18 @@ display: inline-block; } -:host([active]) { +:host([_is-busy]) { color: var(--_ui5_busy_indicator_color); } -:host([active]) :not(.ui5-busy-indicator-root--ie) ::slotted(:not([class^="ui5-busy-indicator-"])) { +:host([_is-busy]) :not(.ui5-busy-indicator-root--ie) ::slotted(:not([class^="ui5-busy-indicator-"])) { opacity: 0.6; } /** * IE fix: 0.6 makes the content almost invisible, so we set it to 0.95 in IE */ -:host([active]) .ui5-busy-indicator-root--ie ::slotted(:not([class^="ui5-busy-indicator-"])) { +:host([_is-busy]) .ui5-busy-indicator-root--ie ::slotted(:not([class^="ui5-busy-indicator-"])) { opacity: 0.95; } diff --git a/packages/main/test/pages/BusyIndicator.html b/packages/main/test/pages/BusyIndicator.html index 418cca8aa121..845d3beba275 100644 --- a/packages/main/test/pages/BusyIndicator.html +++ b/packages/main/test/pages/BusyIndicator.html @@ -172,6 +172,20 @@ + +
+
+ Indicator with delay +
+ Open dialog + + + Will become busy after 5 seconds + Shouldn't attempt to focus the busy indicator + + focus stop + + diff --git a/packages/main/test/specs/BusyIndicator.spec.js b/packages/main/test/specs/BusyIndicator.spec.js index 185d89fefbdf..045362c0b182 100644 --- a/packages/main/test/specs/BusyIndicator.spec.js +++ b/packages/main/test/specs/BusyIndicator.spec.js @@ -85,11 +85,26 @@ describe("BusyIndicator general interaction", () => { it("test inactive indicator in dialog - correct element from default slot is focused", async () => { await browser.$("#open-dialog-inactive-indicator").click(); - let activeElement = await browser.getActiveElement(); + const activeElement = await browser.getActiveElement(); assert.strictEqual( await browser.$(activeElement).getAttribute("id"), await browser.$("#dialog-inactive-indicator-focused-button").getAttribute("id"), "Correct element from default slot is focused" ); + + await browser.keys("Escape"); + }); + + it("delayed indicator in dialog - shouldn't attempt to focus before the indicator is visible", async () => { + await browser.$("#open-dialog-delayed-indicator").click(); + + const activeElement = await browser.getActiveElement(); + assert.strictEqual( + await browser.$(activeElement).getAttribute("id"), + "dialog-delayed-indicator-focus-stop", + "Correct element is focused" + ); + + await browser.keys("Escape"); }); });