vaadin-component-factory / multi-combo-box-flow

https://incubator.app.fi/multi-combo-box-flow-demo/
Apache License 2.0
3 stars 1 forks source link

MultiComboBox can't load more than 500 selected items #14

Open gero1992 opened 3 years ago

gero1992 commented 3 years ago

Hi all! First of all great component, very good job:).

Unfortunately I found a very serious bug, when the user selects more than 500 items and then try to open the popup again. It's not a common usecase, but I think there shouldn't be situations when the component can break like this.

Steps to reproduce:

Result:

Expected result:

Code snippet:

MultiComboBox<String> multiComboBox = new MultiComboBox<>();

List<String> list = IntStream.range(0, 501)
                .mapToObj(index -> "Dummy item " + index)
                .collect(Collectors.toList());
multiComboBox.setItems(list);
add(multiComboBox);

Demo: multi_combo_bug

Best regards, Gero

jcgueriaud1 commented 3 years ago

Hi,

I can reproduce the error. Currently the component is trying to focus the first unselected item. When you have a lot of selected items, the focus is navigating from 0 to 500 then loop back to 0 ...

As a workaround you can increase the pageSize (= the size of the list) but it will send all the items to the client side.

I'll try to, at least, avoid the infinite loop.

jcgueriaud1 commented 3 years ago

I've added a condition to avoid an infinite loop when more than 500 items are selected: https://github.com/vaadin-component-factory/multiselect-combo-box/issues/23

It's released in 0.4.0

gero1992 commented 3 years ago

Hi, sorry for the late response and thanks for your fast reaction!

Yes now it doesn't break, but I don't know if that's the best way to solve the problem. I really like the focus functionality, but maybe the best solution is to remove it, because it's slow and with more than 500 items it doesnt work that good.

Another solution, which I can propose would be to get the focused index on the server side and set it from there.

On the other hand I noticed another bug, which comes from the key mapper which can generate a new key for an already checked item. Whenever the item receives a new key, it won't be shown as checked. If the items have unique keys, which don't change, this will not occur.