diff --git a/packages/main/src/List.js b/packages/main/src/List.js
index 3cfcc978392d..b554d3dc88c3 100644
--- a/packages/main/src/List.js
+++ b/packages/main/src/List.js
@@ -167,12 +167,15 @@ const metadata = {
* @event
* @param {Array} selectedItems an array of the selected items.
* @param {Array} previouslySelectedItems an array of the previously selected items.
+ * @param {Boolean} selectionComponentPressed a boolean indicating if the user used the selection components
+ * in SingleSelection(ui5-radiobutton) and MultiSelection(ui5-checkbox) modes to change the selection.
* @public
*/
selectionChange: {
detail: {
selectedItems: { type: Array },
previouslySelectedItems: { type: Array },
+ selectionComponentPressed: { type: Boolean },
},
},
},
@@ -289,11 +292,15 @@ class List extends UI5Element {
this._selectionRequested = true;
if (this[`handle${this.mode}`]) {
- selectionChange = this[`handle${this.mode}`](event.detail.item, event.selected);
+ selectionChange = this[`handle${this.mode}`](event.detail.item, event.detail.selected);
}
if (selectionChange) {
- this.fireEvent("selectionChange", { selectedItems: this.getSelectedItems(), previouslySelectedItems });
+ this.fireEvent("selectionChange", {
+ selectedItems: this.getSelectedItems(),
+ previouslySelectedItems,
+ selectionComponentPressed: event.detail.selectionComponentPressed,
+ });
}
}
@@ -448,8 +455,9 @@ class List extends UI5Element {
this.onSelectionRequested({
detail: {
item: pressedItem,
+ selectionComponentPressed: false,
+ selected: !pressedItem.selected,
},
- selected: !pressedItem.selected,
});
}
diff --git a/packages/main/src/ListItem.hbs b/packages/main/src/ListItem.hbs
index 89161f436868..127f7ece6612 100644
--- a/packages/main/src/ListItem.hbs
+++ b/packages/main/src/ListItem.hbs
@@ -33,7 +33,8 @@
+ ?selected="{{selected}}"
+ @click="{{onSingleSelectionComponentPress}}">
{{/if}}
@@ -41,7 +42,8 @@
+ ?checked="{{selected}}"
+ @click="{{onMultiSelectionComponentPress}}">
{{/if}}
@@ -51,7 +53,7 @@
id="{{_id}}-deleteSelectionElement"
design="Transparent"
icon="sap-icon://decline"
- @ui5-press="{{_onDelete}}"
+ @ui5-press="{{onDelete}}"
>
{{/if}}
diff --git a/packages/main/src/ListItem.js b/packages/main/src/ListItem.js
index 9b2381b735ef..0ada75521440 100644
--- a/packages/main/src/ListItem.js
+++ b/packages/main/src/ListItem.js
@@ -182,14 +182,26 @@ class ListItem extends ListItemBase {
this.fireItemPress();
}
+ /*
+ * Called when selection components in Single (ui5-radiobutton)
+ * and Multi (ui5-checkbox) selection modes are used.
+ */
+ onMultiSelectionComponentPress(event) {
+ this.fireEvent("_selectionRequested", { item: this, selected: !event.target.checked, selectionComponentPressed: true });
+ }
+
+ onSingleSelectionComponentPress(event) {
+ this.fireEvent("_selectionRequested", { item: this, selected: !event.target.selected, selectionComponentPressed: true });
+ }
+
activate() {
if (this.type === ListItemType.Active) {
this.active = true;
}
}
- _onDelete(event) {
- this.fireEvent("_selectionRequested", { item: this, selected: event.selected });
+ onDelete(event) {
+ this.fireEvent("_selectionRequested", { item: this, selectionComponentPressed: false });
}
fireItemPress() {
diff --git a/packages/main/test/sap/ui/webcomponents/main/pages/List_test_page.html b/packages/main/test/sap/ui/webcomponents/main/pages/List_test_page.html
index 0065a7c43b04..d6b441944abc 100644
--- a/packages/main/test/sap/ui/webcomponents/main/pages/List_test_page.html
+++ b/packages/main/test/sap/ui/webcomponents/main/pages/List_test_page.html
@@ -42,6 +42,14 @@
DVD set
+
+ Option #1
+ Option #2
+ Option #3
+
+
+
+