Open k-grube opened 2 years ago
Thanks!
As you said, this is a bug, or rather a design flaw. Need to add support for fully controllable values. Right now the internal value is always updated. Workaround below but will keep this open until a fix is released.
The onChange handler is set after the value has been updated. What happens in your code is that you stop tracking the value after 2 has been chosen. What you need to do is to slice the values in your else
, like this:
setValue(values.slice(0, 2));
Describe the bug A clear and concise description of what the bug is.
To Reproduce https://codesandbox.io/s/busy-thompson-zhldb?file=/src/App.js
Expected behavior selected values should reflect the value prop passed in
Screenshots See code sandbox
Desktop (please complete the following information):
Additional context It seems to me like this should work, but if there's a different way to handle controlling this input I would love to know how.