ProgressNS / nativescript-ui-feedback

This repository is used for customer feedback regarding Telerik UI for NativeScript. The issues system here is used by customers who want to submit their feature requests or vote for existing ones.
Other
115 stars 21 forks source link

RadListView itemSelecting event not firing if the same item is tapped twice in vue. #1390

Closed eskalVAR closed 4 years ago

eskalVAR commented 4 years ago

Versions CLI: 6.5.0 tns-android: 6.5.0 nativescript-ui-listview: 8.11

Description When using the RadListView from nativescript-ui-listview/vue the itemSelecting event does not fire again if the same item is twice after setting the returnValue of the event to

How to reproduce + details I am trying to limit the number of items that can be selected in a RadListView using the following code:

onItemSelecting(event) {
    if (event.object.getSelectedItems().length >= maxSelectedItems) {
        event.returnValue = false;
    }
}

Say the max items is 3. Upon selecting the 4th item (say index 6) the returnValue stops the 4th item from being selected and the itemSelecting event is fired. If another item (say index 10) is tapped on it also works. This method does not stop selection if the same item is taped consecutively.

If the same item is tapped a few times the following happens:

Tap 1 : itemSelecting event fired, itemSelected NOT fired, selection stops Tap 2 : itemSelecting event NOT fired, itemSelected fired, selection succeeds Tap 3 : itemSelecting event fired, itemSelected NOT fired, selection stops Tap 4 : itemSelecting event NOT fired, itemSelected fired, selection succeeds

..... and continues like this

I have only tested this on android, both on my personal device and an emulator.

The RadListView is populated using the for property and a standard JS object.

eskalVAR commented 4 years ago

Did some digging into code (I know NDA is required hence specifics will not be provided) In ui-listview-android.js line 270 and line 539. The issue is to do with how duplicate event firing checks are handled.

eskalVAR commented 4 years ago

A temporary workaround is just remove the check. This does mean the itemSelecting event is fired twice after 1 tap though. Any information on what calls ListViewAdapter.canSelect would be great to find out why this double firing event occurs.

lini commented 4 years ago

Thanks for the information. We will take a look and release a fix with the next listview plugin update.

lini commented 4 years ago

Hi, A new version of RadListView was recently released (8.1.2) that includes a fix for the onItemSelecting/onItemDeselecting behavior. Give it a try and see if it works as expected.

eskalVAR commented 4 years ago

Your fix works, thank you for getting it done so quickly.