react-spectrum
react-spectrum copied to clipboard
[useComboBox] Async Loading example unexpected behavior
🐛 Bug Report
Steps to reproduce:
- Load sandbox link
- type in "jarr"
- Observe expected no options in list
- press backspace once, query is "jar"
- No results appear, though I would expect "Jar Jar Binks" to show up.
🤔 Expected Behavior
"Jar Jar Binks" to show up like when typing "jar"
😯 Current Behavior
I was expecting "Jar Jar Binks" to show up. It could also be my own error and I'm not understanding the expected autocomplete behavior just figured it was worth filing.
🔦 Context
Just testing out the behavior of the code samples while evaluating the library for use.
💻 Code Sample
https://codesandbox.io/s/dreamy-burnell-3i2jy?file=/src/App.tsx
I've reproduced the issue as well. I can additionally say that displaying (by console.log()) load function results showing that component receives options/suggestions on every single key enter, but for some reason it doesn't render the last final retrieved result set.
I believe this is in the same vein as https://github.com/adobe/react-spectrum/issues/2333, essentially we have a double render that breaks logic that handles opening the menu automatically on input change. For our RSP ComboBox we opted to display the menu even if there weren't any items to display which sidestepped the issue you are seeing above.
I ran into this issue as well. As @LFDanLu manetioned, the only way to fix this (at present) is to use
const state = useComboBoxState({
...props,
allowsEmptyCollection: true,
});