gatanaso/multiselect-combo-box-flow

Value of the field is lost when filtering

Closed this issue · 4 comments

When i use a ConfigurableFilterDataProvider and setFilter then the value of the field is lost.

Hi @pbaris,

Thank you for reporting this issue.

Could you please provide more details, i.e. what are you trying to achieve, and what is the expected behavior? Ideally, adding a code snippet or a reproducible example would be very much appreciated.

BR

Having the code

ConfigurableFilterDataProvider<String, Void, SerializablePredicate<String>> dataProvider 
    = DataProvider.ofItems("A", "B", "C", "D", "E", "F").withConfigurableFilter();

MultiselectComboBox<String> comboBox = new MultiselectComboBox<>();
comboBox.setDataProvider(dataProvider);

comboBox.setValue(new HashSet<>(Arrays.asList("B", "D")));

Button btn = new Button("filter");
btn.addClickListener(e -> dataProvider.setFilter(d -> !d.equals("A")));

when button is clicked the dataprovider filters the items and all items except A are available to select.
But combobox lose the value (selectedItems).

Thank @pbaris for providing more details. From a first glance it looks like when a filter is set the data provider is updated and the component calls reset() which also clears the current value. I will need to investigate this behavior further.

Hi @pbaris

I have investigated your sample further, and not clearing the value when a filter is set produces the following outcome:
filter-combo-box

update: IMHO the above behavior is what would be expected from this component.

BR,
Goran