-
Notifications
You must be signed in to change notification settings - Fork 2.4k
fix(ui): relationship using list drawer correctly updates when hasMany is true #12176
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
fix(ui): relationship using list drawer correctly updates when hasMany is true #12176
Conversation
…en hasMany = true
Thanks |
@jacobsfletch I updated the listDrawerFilterOptions function as I was getting an error when trying to set the filterOptions with polymorphic relations but maybe there is a way to simplify? |
@swheeler7 I tested this fix on my project, but something is still not right. For example, elements now might not appear after two if the element is unknown (i.e., if it wasn't previously selected, it doesn't appear). Filtering with hasMany true still doesn't work. I'll also try to look into what the problem might be. |
Weird this is what it's looking like for me when I run the fix locally but I could be missing or not understanding the specific case you are talking about: relationship-drawer-fix.movIf you have a specific field configuration where it's not working I can try to take a look |
@swheeler7 So, indeed, everything works perfectly. I didn't notice that I hadn't replaced the package. Sorry, my mistake. Everything works great within my use case. |
Is there anything that's blocking from merging this PR? The relationship drawer is pretty much unusable without this fix. |
@swheeler7 one thing I noticed, if you have a dropdown to select a collection and press the 'X' next to it, the entire UI crashes. |
It looks like this is an issue with the ListDrawer component itself, not specifically it's usage here in the relationship field. This will be an issue anywhere the ListDrawer is used which I think is in the Lexical Relationships feature, the uploads feature, and I think the new query presets feature. Maybe open an issue for it, but if I have time I'll try to create a PR to fix |
🚀 This is included in version v3.36.0 |
What?
This fixes an issue raised by @maximseshuk in this PR #11553. Here is the text of the original comment:
If the field has the property hasMany: true and you select one item, it shows up in the select field, but any additional selected items won't be visible in the select field, even though the data is actually there and can be saved. After refreshing the page, they appear.
In addition I added a fix to an issue where the filterOptions weren't being passed in to the useListDrawer hook properly in polymorphic relationships
How?
Instead of using the push method to update the value state, a new array is created and directly set using useState. I think the issue was because using push mutates the original array.