payload
payload copied to clipboard
[3.0] isSortable not working as expected on relationship field
Link to reproduction
No response
Describe the Bug
When using the isSortable
admin config option with a relationship field (whilst also using hasMany
), I expect to be able to sort the selected items.
However this is not the case and the select menu functions as a typical hasMany
select and items cannot be dragged/sorted.
To Reproduce
I have a posts
collection with the following field for related categories
:
{
name: 'categories',
label: 'Categories',
type: 'relationship',
relationTo: 'categories',
hasMany: true,
admin: {
isSortable: true,
},
},
I would expect the Categories field to be sortable.
Payload Version
3.0.0-beta.21
Adapters and Plugins
No response
I have exactly the same problem, 3.0.0-b24 in my case
Hi @joedawson , I'm taking a look at this!
Any news on this one?
Thanks for fixing @JarrodMFlesch - confirming this works now in 3.0.0-beta.37
.
Not really much of an issue for my use case currently, but I think there may have been a knock-on issue as a result of this fix.
Fields are sortable, regardless of whether isSortable is set or is false - resulting in hasMany
fields always being sortable. I tested this with relationship
and select
field types.
Again, not really an issue for me currently (personally, I would likely set it to true in most scenarios) - however I don't suspect this is intended.
{
name: 'topics',
label: 'Topics',
type: 'relationship',
relationTo: 'topics',
hasMany: true,
admin: {
isSortable: false, // still sortable
},
},
{
name: 'my_select',
label: 'Select stuff',
type: 'select',
options: [
// ...
],
hasMany: true,
admin: {
// omitting isSortable entirely, still sortable - however unsure of the default but suspect it would be false.
}
},
@joedawson good catch. I don't think this was caused bc of the fix, more so, it was able to be reproduced bc of the fix. Since you were not able to sort before and now you can. I can look into this 👍
@joedawson PR here.
This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.