openui5 icon indicating copy to clipboard operation
openui5 copied to clipboard

Bug in BaseList when retrieving selected items after filter

Open kyakubi opened this issue 9 years ago • 5 comments

OpenUI5 version: Latest

I think this is quite easy to replicate.

  1. Make a list with some filters and apply one filter.
  2. Select a few items
  3. Apply another filter (the filter should hide a couple of the selected ones)

Look how 3 methods (that should return the same) react...

image

The one that is correct is ofcourse the getSelectedContextPaths because the other items are still selected but only hidden after the second filter.

kyakubi avatar Nov 01 '17 14:11 kyakubi

As far as I know, this is on purpose and it's the expected behavior.

Did you check the property rememberSelections of ListBase?

image

fabiopagoti avatar Nov 01 '17 18:11 fabiopagoti

@fabiopagoti I dont think that property is appropriate in this case. For instance I do the sorting/filtering on the front-end not in the back-end so the model never changes.

Also it doesn't make sense that the three methods get different results if they all point to "selected" items. I think its clearly a bug and in this case the bug is in the first two...the data model never changes only what is shown.

kyakubi avatar Nov 02 '17 08:11 kyakubi

Hello @kyakubi , Thank you for sharing this finding. I've created an internal incident 1780415769. The status of the issue will be updated here in GitHub. Regards, Diana

Shtilianova avatar Nov 21 '17 13:11 Shtilianova

@fabiopagoti getSelectedContexts is a private method you should never use it. "item" is a Control representation and if a previously selected item is not visible at the current filter the item will be destroyed and will not be present in the items aggregation therefore getSelectedItems can only return the selecteds which are in the items aggregation. Contexts are reference to the model data records. Since they always exists (actually they do not in ODataV4 but anyway) getSelectedContexts can return the selected item contexts even before filter. If you need previously selected contexts then you should pass true as a 1st parameter e.g. getSelectedContexts(true) Please note that these are all related with the rememberSelections property.

aborjinik avatar Nov 27 '17 09:11 aborjinik

Half year I can still see the same issue. (even when you call it a feature :D)

Check this scenario:

A user wants to use the checkboxes and changes the list to multi selection. He then uses a filter checks a couple of properties and changes the filter again and chooses again a couple of items.

BUT he clicked on one of the items without checking the checkbox. If you do getSelectedItems it will return only the visible items. if you do getSelectedContexts(true) you will get all with checkbox AND the one you just clicked but not checked.

That's a bug not a feature...

kyakubi avatar Apr 26 '18 14:04 kyakubi