FlowingCode/ChipFieldAddon

How to get the chip Object on delete / click

Closed this issue · 1 comments

Hi, at the moment when a Chip is clicked or deleted, I can get the chip label by the event.getLabe().

In my case I pass an objet to the chipField " ChipField....."
How can I get the MyObject on click / delete ?

Thanks

Hello. The component uses the label for identifying chips in the client side,

private final Map<String, T> selectedItems = new HashMap<>();

but the mapping is not exposed through public API, so, we'll need to implement a mechanism that allows retrieving an item given its value. Indeed, that's the approach in Grid's listeners:
https://github.com/vaadin/vaadin-flow-components/blob/master/vaadin-grid-flow-parent/vaadin-grid-flow/src/main/java/com/vaadin/flow/component/grid/ItemClickEvent.java#L83-L99