List State: `collection.getItem()` can return `undefined`
#5.776 aberto em 30 de jan. de 2024
Métricas do repositório
- Stars
- (15.634 stars)
- Métricas de merge de PR
- (Métricas PR pendentes)
Description
Provide a general summary of the issue here
Well. I have a very hard to reproduce bug - it's randomly happening - and hard to check in the current repo the returned type. So, I build a Combobox thanks to the hooks and load async some data to fill the items - with or without useAsyncList btw - and sometimes I receive:
Uncaught TypeError: Cannot read properties of undefined (reading 'index')
at useListState.ts:81:21
so looks like that here https://github.com/adobe/react-spectrum/blob/b5974ad1ccf2abc984c5cc6664b3c2d03de36768/packages/%40react-stately/list/src/useListState.ts#L63 collection.getItem() can return undefined
🤔 Expected Behavior?
It doesn't crash ^_^
😯 Current Behavior
It does crash :-/
💁 Possible Solution
No response
🔦 Context
No response
🖥️ Steps to Reproduce
It's a very hard issue to reproduce and hard to have an easy example unfortunately. I can't have a setup with the current reop that returns another type that "any", so it's really hard to find out what happens.
The only thing I know it that you need to:
- open the combobox
- put some text (not necessarily needed)
- select an item
- it reloads the items list because filterText changed (set by the selection)
- clean the selected Item
- it reloads the first 50 items (filterText = "")
- repeat
as fast as you can to trigger it. I feel like checking the possible returned value of getItem would be easier but I was unsuccessful here.
Version
latest
What browsers are you seeing the problem on?
Chrome
If other, please specify.
No response
What operating system are you using?
Windows
🧢 Your Company/Team
No response
🕷 Tracking Issue
No response