FlowingCode / ChipFieldAddon

Vaadin Flow integration of https://github.com/ThomasCybulski/paper-chip
Apache License 2.0
7 stars 5 forks source link

How to get the chip Object on delete / click #26

Closed ado2000 closed 3 years ago

ado2000 commented 3 years ago

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

javier-godoy commented 3 years ago

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

https://github.com/FlowingCode/ChipFieldAddon/blob/5e63c61626d46c2eb7a3530dbd1decbee48cde86/src/main/java/com/flowingcode/vaadin/addons/chipfield/ChipField.java#L73

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