diff --git a/packages/main/src/BusyIndicator.hbs b/packages/main/src/BusyIndicator.hbs index 49b34a776659..681abd9f2b1b 100644 --- a/packages/main/src/BusyIndicator.hbs +++ b/packages/main/src/BusyIndicator.hbs @@ -1,7 +1,7 @@
{{#if active}} -
+
diff --git a/packages/main/src/BusyIndicator.js b/packages/main/src/BusyIndicator.js index 64d295f267c4..b4fdc671d007 100644 --- a/packages/main/src/BusyIndicator.js +++ b/packages/main/src/BusyIndicator.js @@ -95,6 +95,30 @@ class BusyIndicator extends UI5Element { super(); this.i18nBundle = getI18nBundle("@ui5/webcomponents"); + this._preventHandler = this._preventEvent.bind(this); + } + + onBeforeRendering() { + if (this.active) { + this.tabIndex = -1; + } else { + this.tabIndex = 0; + } + } + + onEnterDOM() { + this.addEventListener("keyup", this._preventHandler, { + capture: true, + }); + + this.addEventListener("keydown", this._preventHandler, { + capture: true, + }); + } + + onExitDOM() { + this.removeEventListener("keyup", this._preventHandler, true); + this.removeEventListener("keydown", this._preventHandler, true); } static get metadata() { @@ -123,6 +147,12 @@ class BusyIndicator extends UI5Element { get ariaTitle() { return this.i18nBundle.getText(BUSY_INDICATOR_TITLE); } + + _preventEvent(event) { + if (this.active) { + event.stopImmediatePropagation(); + } + } } BusyIndicator.define(); diff --git a/packages/main/test/pages/BusyIndicator.html b/packages/main/test/pages/BusyIndicator.html index 81c7d09428ff..6ccd82c951c8 100644 --- a/packages/main/test/pages/BusyIndicator.html +++ b/packages/main/test/pages/BusyIndicator.html @@ -112,6 +112,24 @@

+ + +
+ Dynamic tree +
+ + + + + + + + + +
+
+ + diff --git a/packages/main/test/specs/BusyIndicator.spec.js b/packages/main/test/specs/BusyIndicator.spec.js new file mode 100644 index 000000000000..0cfa3c7ea08f --- /dev/null +++ b/packages/main/test/specs/BusyIndicator.spec.js @@ -0,0 +1,18 @@ +const assert = require("chai").assert; + + +describe("BusyIndicator general interaction", () => { + browser.url("http://localhost:8080/test-resources/pages/BusyIndicator.html"); + + it("tests event propagation", () => { + const busyIndicator = browser.$("#busy-tree"); + const dynamicItem = busyIndicator.$("ui5-tree").shadow$("ui5-list").$$("ui5-li-tree")[2].shadow$(".ui5-li-tree-toggle-box"); + const input = browser.$("#tree-input"); + + dynamicItem.click(); + dynamicItem.keys("Space"); + + assert.strictEqual(input.getProperty("value"), "0", "itemClick is not thrown"); + }); + +});