#Sorting hasMany relationships

8 messages · Page 1 of 1 (latest)

lethal flicker
#

The documentation mentions that hasMany relationship fields can be made sortable using the isSortable admin option:
https://payloadcms.com/docs/fields/relationship#admin-options

This doesn't seem to have any effect for me, am I doing something wrong?

{
   type: 'relationship',
   label: 'Boxes',
   name: 'items',
   relationTo: 'iconBoxes',
   required: true,
   hasMany: true,
   admin: {
      isSortable: true
    }
}

The items cannot be dragged or sorted in any other way that I can figure out (see attached screenshot).

eager zealot
#

What payload version are you currently using?

lethal flicker
#

Currently on 3.78.0

eager zealot
#

Weird. I have a relationship field without

admin: {
isSortable: true,
},

And i can still sort my relationship field. Could you try removing admin: {} and see if its sortable then?

lethal flicker
#

Nope, still not working. I'm using some other hasMany relationship fields in other collections and none of them are allowing me to sort it seems. Tried a different browser too just in case. When I hover over one, the cursor changes to a "grabbing" hand icon but trying to click and drag and nothing happens.

#

But, if it works for you then my guess is this is being caused by something in my payload setup. I will try some things and come back later

lethal flicker
#

Whatever is causing it, it seems to be something introduced in 3.78.0. If I rollback to 3.77.0 drag and drop reordering of relations works perfectly. Upgrading back to 3.78.0 makes it stop working again.