react-spectrum icon indicating copy to clipboard operation
react-spectrum copied to clipboard

[useComboBox] Async Loading example unexpected behavior

Open Blitz2145 opened this issue 3 years ago • 2 comments

🐛 Bug Report

Steps to reproduce:

  1. Load sandbox link
  2. type in "jarr"
  3. Observe expected no options in list
  4. press backspace once, query is "jar"
  5. 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"

image

😯 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.

image

🔦 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

Blitz2145 avatar Aug 09 '22 21:08 Blitz2145

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.

nickolaylavrinenko avatar Aug 09 '22 22:08 nickolaylavrinenko

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.

LFDanLu avatar Aug 09 '22 23:08 LFDanLu

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,
  });

moonray avatar Sep 20 '23 01:09 moonray