-
Notifications
You must be signed in to change notification settings - Fork 1.2k
ListBox fails when refreshing items because internal state is somehow broken #977
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@tomsontom This feels tantalizingly familiar, feel like I've encountered this previously when working on an earlier iteration of ComboBox. Would you mind sharing a code snippet of how you set up your ListBox? Would you happen to be using |
Well it is hard come up with something you can work with but there are some data points:
My current workaround is to not refill the list but by changing the "key" to make sure I always attach a new one. |
Here is a simple example to reproduce the bug. It happens when clicking on the button to replace the list items.
|
@christian-baumann Thanks for the code snippet, but I'm having difficulties reproducing the bug with it. Clicking the button properly replaces the items, at least with |
I can reproduce the problem using react-spectrum and i instrumented the useOption-code js-code a bit and I see the following logged: The code I added is: console.debug("Update: ", "key:", key, "collection:", state.collection, "item: ", state.collection.getItem(key)) when the list is replaced it still sends "item1" as the key to the useOptions() who is not there any more hence it fails. |
another interesting observation is - if I fix the index access by changing the if if (isVirtualized && state.collection.getItem(key)) { the list is not refilled until i resize the window |
@LFDanLu Originally I have tested it with version 3.3.0 but I have also tested it with 3.2.0 and 3.1.0. The error happens with both, Firefox and Chrome. I have pushed a small sample project to reproduce the problem: |
@tomsontom @christian-baumann Ahh, thanks, I can see the error now. Interesting that it doesn't happen in my codesandbox but it does in the react-create-app, will have to dig |
Seems to only happen when a wrapping |
Umbrella issue for strict mode: #779 |
🐛 Bug Report
In my real world application I can get ListBox into a state to display the following error:
I've tried to create a reproducer but failed to do so until now. This happens when I try to update the items after a server request returned the items i want tu populate the list with.
🤔 Expected Behavior
The list updates the items
😯 Current Behavior
Above stack trace where somehow the internal state is somehow broken
💁 Possible Solution
I've not yet foudn any workaround and as I've been unable yet to publish a custom version with some debug information I'm unable to findout what is going on (and why my use of ListBox causes this error)
🔦 Context
💻 Code Sample
🌍 Your Environment
🧢 Your Company/Team
🕷 Tracking Issue (optional)
The text was updated successfully, but these errors were encountered: