[Combobox] Issue with auto-selecting first item in Combobox when using useDeferredValue
#3231
Open
1 of 3 tasks
Labels
Description
I'm trying to optimize the
Combobox
component for cases where rendering the items takes a long time. My approach is based onuseDeferredValue
, as explained in the React docs.I'll provide a reproduction example with three variations:
useDeferredValue
.The issue
In some cases, auto-selecting the first element in the results doesn’t work correctly when combining the combobox with
useDeferredValue
.My hunch
The first-item detection seems to happen inside
Combobox.Root
usingcollection
. Could we move this logic<Combobox.List>
component so React can better control the execution order? This way, the first-item selection would align more with the chunk of work handled by the list rendering.Recordings:
deferred.mp4
deferred.2.mp4
This issue is tricky to reproduce consistently, as the behavior isn't constant. You may need to enter the search string multiple times to observe the problem.
Github repo: https://github.com/isBatak/react-ark-ui-combobox-optimization-issue
Link to Reproduction (or Detailed Explanation)
https://stackblitz.com/~/github.com/isBatak/react-ark-ui-combobox-optimization-issue?file=src/App.tsx
Steps to Reproduce
No Optimization:
Slow Example:
Deferred Example:
Ark UI Version
4.8.1
Framework
Browser
Chrome
Additional Information
No response
The text was updated successfully, but these errors were encountered: