alsoscotland / react-super-select

MIT License
95 stars 33 forks source link

An option to clear the selected items by an external control #134

Closed ghost closed 6 years ago

ghost commented 6 years ago

Hi Scotland

Can we have an option to clear the selected values on react-super-select by an external control event .

Lets say . A component is created with an external checkbox say "ANY" or "ALL" along with the react-super-select . On selection/unselection of the items in the dropdown, selection/unselection/displaying of tags in place holder works fine but clicking on external control "ANY" or "ALL" does not clear the placeholder and the react-super-select state object is not reset to default. We can actually achieve the behaiviour with the initialFormValue change per selection but its triggering the onchange event TWICE which does not seem to be right.

Please ignore the first commit:)

alsoscotland commented 6 years ago

@sivasankar1234 I don't think this really makes sense to do this way.
This would mean that in any render cycle the selected options would clear once that boolean has been set.

Setting the initialValue as empty is the correct way to clear the control from an external source.