SAP / ui5-webcomponents

UI5 Web Components - the enterprise-flavored sugar on top of native APIs! Build SAP Fiori user interfaces with the technology of your choice.
https://sap.github.io/ui5-webcomponents/
Apache License 2.0
1.52k stars 263 forks source link

ui5-list with checkboxes sends incorrect "selected" state #6523

Open jmouka opened 1 year ago

jmouka commented 1 year ago

To reproduce

itemClick(event) {
    console.log(event.detail.item.selected);
}

Clicking on the checkbox gives correct result, but clicking the row gives the opposite results. Looks like the issue is with timing when the row is clicked, because this gives correct result:

itemClick(event) {
    setTimeout(function() {
        console.log(event.detail.item.selected);
    }, 10);
}

Using @ui5/webcomponents 1.10.4, Vue 2.7.14, Node v12.22.12, Npm 6.14.16

niyap commented 1 year ago

Hello @SAP/ui5-webcomponents-topic-p,

If we have ui5-list component with mode="MultiSelect", when the checkbox of an item is pressed, "selection-change" event is fired first, coming from onMultiSelectionComponentPress which is attached on click of the ui5-checkbox and after that ui5-item-click event is fired. On the other hand, if we click over the item, the sequence is different. First the item-click event is fired which then invokes selection-change(check onItemPress method). As a result, when the item is clicked, the selection is not already changed and that is the reason for the result in the provided sample.

Could you please check whether that is the expected behaviour of the component?

Kind Regards, Niya