Closed fabien-ml closed 1 year ago
Sorry, unfortunately I still got an issue related to out of sync controlled value in single select.
Please check example here and follow the explanations on the page: https://stackblitz.com/edit/github-vhpnzf-y71c4s?file=src%2FApp.tsx
In a nutshell, it looks like the Select value needs to be null
in order have correct behavior when unselecting an element, however it's not what TypeScript expect (eg. it expects Fruit | Fruit[] | undefined
).
Generally, I think null
should be avoided:
https://medium.com/@hbarcelos/why-i-banned-null-from-my-js-code-and-why-you-should-too-13df90323cfa
Therefore, in my opinion, onChange
should give undefined
when nothing is selected, and value
should expect undefined
for unselected state.
When having a controlled value, I see the select being out of sync in 0.10.0. It can be reproduced in the documentation page.
Apple
Apple
Apple
, controlled value is empty (eg. it showsYour favorite fruit is: .
). This happens most of the time for me, but not always.Luckly for me I need
disallowEmptySelection: true
, so that issue is currently not relevant for me (I had to specify this explicitly, since the default value changed in 0.10.0. This is the reason I started to look into this).Originally posted by @jcmonnin in https://github.com/kobaltedev/kobalte/issues/229#issuecomment-1689992206