How can i get last selected value from List box

I’m trying to get the last selected item from list box, there is a way to get this value ?
The only data that I got is the list for all of the items, and I’m trying to get only the last selected

Hey @Matanbenhemo :wave:

You can try doing something like keeping a record of what options have been selected that you can compare to whenever a user selects a new option. To store the record you might consider using a temp state below is an example that also uses lodash's difference function to compare the two arrays.

const lastSelection = _.difference(multiSelectListbox.value, previousSelectionTempstate.value);
return lastSelection[0];

It's written to go in a JS query that you can set as a Change event handler for your component. Let me know if that helps!