adobe/react-spectrum

Async Combobox not rendering initial result

Open

#5234 aperta il 10 ott 2023

Vedi su GitHub
 (22 commenti) (8 reazioni) (1 assegnatario)TypeScript (1500 fork)auto 404
ComboBoxbughelp wanted

Metriche repository

Star
 (15.634 star)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

Provide a general summary of the issue here

combobox does not render a list of results from an initially empty or undefined list given a search query. however each subsequent query change will render a list.

🤔 Expected Behavior?

Combobox popover should render a list of results from an initially empty or undefined async response in the first instance.

😯 Current Behavior

At present, the current example provided by the docs for an async combobox does an initial fetch on page render. great for small lists, not so great for searching for an amazon product or returning an address from google places api. I added a small predicate in the useAsyncList list callback to only search when the filterText length is greater than 0. this takes care of the initial fetch however it appears the popover is now no longer synced with the state of the combobox because when there IS a list of results in the first instance, popover does not render a list. however with each new request after the first one that has results, it will flash the initial list before quickly showing the 'current' list.

💁 Possible Solution

No response

🔦 Context

No response

🖥️ Steps to Reproduce

Example can be found here Its taken straight from the docs example under the RAC combobox async docs (an actual async RAC combobox code example would be nice though). all ive added is a console log to track the items passed to combobox and a predicate to prevent initial render.

  1. open link provided above, observe console log to see full initial list returned on page load.
  2. uncomment first line in useAsyncList 'load' callback to prevent initial fetch
  3. type in letter 'L' (lowercase) and watch for console output of returned list with no initial popover being rendered
  4. type in letter 'u' and observe the 'initial' results list immediately render until its replaced by the new list

Version

3.29.0 (react-aria)

What browsers are you seeing the problem on?

Chrome

If other, please specify.

No response

What operating system are you using?

Windows 11

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

Guida contributor