Fix Unexpected undefined
crash in Combobox
component with virtual
mode
#3678
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes an issue where the
Combobox
component crashes if you are using thevirtual
option and you quickly type something such that theCombobox
opens but no valid options are available.We already check if the current active index is available in the internal
options
list. However, if you then callvirtualizer.scrollToIndex(data.activeOptionIndex)
it will crash if you are too fast.Screen.Recording.2025-04-04.at.12.53.40.mov
If you are typing slowly, then it will work as expected.
Screen.Recording.2025-04-04.at.12.54.01.mov
I did find an open issue on TanStack's repo about this: TanStack/virtual#879
This PR is basically a workaround by delaying the call. But it does have the expected behavior now.
Screen.Recording.2025-04-04.at.12.57.40.mov
Fixes: #3583