From 3f66c068493cc6de65ef315500e4fe78f9a74709 Mon Sep 17 00:00:00 2001 From: Filip Siderov Date: Thu, 19 Nov 2020 10:15:01 +0200 Subject: [PATCH] fix(ui5-li-custom): prevent firing of events (#2462) --- packages/main/src/CustomListItem.js | 16 +++++++++++ packages/main/test/pages/List_test_page.html | 29 ++++++++++++++++++++ packages/main/test/specs/List.spec.js | 24 +++++++++++----- 3 files changed, 62 insertions(+), 7 deletions(-) diff --git a/packages/main/src/CustomListItem.js b/packages/main/src/CustomListItem.js index 78beb3392ec2..7bb17ed97295 100644 --- a/packages/main/src/CustomListItem.js +++ b/packages/main/src/CustomListItem.js @@ -53,6 +53,22 @@ class CustomListItem extends ListItem { return [ListItem.styles, customListItemCss]; } + _onkeydown(event) { + if (!this.focused) { + return; + } + + super._onkeydown(event); + } + + _onkeyup(event) { + if (!this.focused) { + return; + } + + super._onkeyup(event); + } + get classes() { const result = super.classes; result.main["ui5-custom-li-root"] = true; diff --git a/packages/main/test/pages/List_test_page.html b/packages/main/test/pages/List_test_page.html index 1b2312f65fb3..752877682ae3 100644 --- a/packages/main/test/pages/List_test_page.html +++ b/packages/main/test/pages/List_test_page.html @@ -154,6 +154,26 @@

Test aria

HP Monitor 24 Change empty item text +
+ Events within ui5-li-custom +
+ + + + List Button 1 +
+
+ + List Button 2 +
+
+ + List Button 2 +
+
+
+ + diff --git a/packages/main/test/specs/List.spec.js b/packages/main/test/specs/List.spec.js index 06c8e498b11d..14ffb37b34d2 100644 --- a/packages/main/test/specs/List.spec.js +++ b/packages/main/test/specs/List.spec.js @@ -8,7 +8,7 @@ describe("List Tests", () => { it("List is rendered", () => { const list = browser.$("ui5-list").shadow$(".ui5-list-root"); - + assert.ok(list, "List is rendered"); }); @@ -79,7 +79,7 @@ describe("List Tests", () => { return result.length; }); - + assert.strictEqual(listItemsLength, 3, "List items are rendered"); }); @@ -246,7 +246,7 @@ describe("List Tests", () => { const listWithCustomHeader = $("#listWithCustomHeader"); const ulInternalHeader = listWithInternalHeader.shadow$(".ui5-list-ul"); const ulCustomHeader = listWithCustomHeader.shadow$(".ui5-list-ul"); - + // assert: List with internal header const listWithInternalHeaderId = listWithInternalHeader.getProperty("_id"); assert.strictEqual(ulInternalHeader.getAttribute("aria-label"), @@ -286,9 +286,19 @@ describe("List Tests", () => { }); // assert - assert.strictEqual(emptyItem.getProperty("innerHTML"), NEW_TEXT, - "The value is updated"); - assert.strictEqual(assignedNodesAfter, 1, - "The new text is slotted."); + assert.strictEqual(emptyItem.getProperty("innerHTML"), NEW_TEXT, "The value is updated"); + assert.strictEqual(assignedNodesAfter, 1, "The new text is slotted."); + }); + + it("tests events for ui5-li-custom", () => { + const button = $("#liBtn1"); + const input = $("#customListItemEvents"); + + button.click(); + + browser.keys("Enter"); + browser.keys("Space"); + + assert.strictEqual(input.getProperty("value"), "0", "item-click event is not fired when the button is pressed."); }); });