FlowingCode / TwinColGridAddon

TwinColGrid Vaadin Add-on
https://www.flowingcode.com/en/open-source/
Apache License 2.0
7 stars 7 forks source link

setValue does not clear the previous value but only add items #100

Closed jcgueriaud1 closed 2 years ago

jcgueriaud1 commented 2 years ago

When I call setValue the old value is kept and concatenated, instead of being set like it should. Is it intended?

For example if you have an entity bound and run setBean it will keep the old values.

Here is an example to reproduce the issue:


@PageTitle("Twin Col Grid")
@Route(value = "twincol", layout = MainLayout.class)
public class TwinColGridView extends VerticalLayout {

    private Button button;
    private TwinColGrid<String> twinColGrid = new TwinColGrid<>("TwinCol");

    private List<String> items = new ArrayList<>();

    public TwinColGridView() {
        for (int i = 0; i < 10; i++) {
            items.add("Item "+ i);
        }
        twinColGrid.addColumn(item -> item, "item");
        twinColGrid.setItems(items.stream());
        twinColGrid.setSizeFull();
        button = new Button("set Value");
        button.addClickListener(e -> {
            twinColGrid.setValue(Collections.singleton(items.stream().findFirst().get()));
        });

        add(twinColGrid, button);
        setSizeFull();
    }

}
javier-godoy commented 2 years ago

When I call setValue the old value is kept and concatenated, instead of being set like it should. Is it intended?

It's not intended. It breaks the contract of setValue.

javier-godoy commented 2 years ago

Fix released in version 2.7.1