Hi there,
I have had a lot of issues while trying to know which value I am selecting or unselecting on the switch group component.
Exemple :
Here, if I unselect "option3" i want to know that the item "option3" has been unselected.
My use case is that I also have a search bar to get into the values of the switch group, but while selecting/unselecting an item having a filter, the switch group doesn't recognize the previous values.
Great question! It seems like you can use Javascript & temporary state to determine the most recently clicked item.
1). Create a temporary state variable, set the initial value to be equal to the default value of the switchGroup
2). Create a JS query that will trigger on change of the switchGroup. The JS query will compare the state value with the current value of the switchGroup, get the difference (i.e. the clicked value), and then it will update the state to the new value of the switchGroup:
Please note, you may have to modify this code if you need to also determine whether the returned value is toggled on or off. This code will just tell you which item was most recently clicked