Manual drag & drop record sorting not working anymore and all have the same position (when records are created in parallel) [edited title]

What is the URL?

Relevant URL: https://digicel-personal-production.admin.datocms.com/environments/development-20260413105138/editor/item_types/CjmUEy4VT1uONWxKhgY4Tg/items

What is the issue?

I need help with: drag & drop is not working. After dropping the state is reset. Attached is a video of the behaviour.

Hello @thomas.vanleynseele

This is indeed a bug on our end, sorry about that.

I’ll get back to you as soon as it is fixed.

Thank you for letting us know!

@thomas.vanleynseele,

It looks like manually changing one of the record positions in the sidebar to some other number fixes this:

I set it to 4 (even though you only have 3 records), and then afterward drag-and-drop worked again for all the records in that model.

Do you happen to know how this model ended up this way? They all had position 1 at first, and it looks like they were created by an API script. Any chance you could share that script with us, please? You can post it here (or the relevant snippet) if it’s not sensitive, or else you can DM me here or email it to support@datocms.com.

We’ll try to find the condition that causes this to happen and fix it. In the meantime, manually editing the position should fix it again.

Sorry about that!

In my testing, I noticed that this can happen if you’re updating records in bulk in parallel, and the re-ordering is racing the updates for other records. Could your script have been doing something like that? (No problem if it was; I’m just trying to better identify the bug so we can fix it)

Hi Roger,

Yes, I can confirm I’m doing bulk create & publish for those records in my script.

    await Promise.all([
      client.items.create({
        item_type: { type: 'item_type', id: deviceBrandModel.id },
        name: 'Apple',
      }),
      client.items.create({
        item_type: { type: 'item_type', id: deviceBrandModel.id },
        name: 'Samsung',
      }),
      client.items.create({
        item_type: { type: 'item_type', id: deviceBrandModel.id },
        name: 'ZTE',
      }),
    ]);

// later on I bulk publish my seeded records.
await Promise.all(seededIds.map((id) => client.items.publish(id)));

Got it, thank you. That matches our internal testing too… it’s a serverside race condition in the position updater. It’s been reported and I’ll let you know once it’s fixed!

In the meantime, as a workaround, you can try one of these:

  • You can assign them an explicit auto-incremented position during creation, e.g.:
     await Promise.all([
          client.items.create({
            item_type: { type: 'item_type', id: deviceBrandModel.id },
            name: 'Apple',
            position: '1' // or an array index if you map() these first
          }),
          client.items.create({
            item_type: { type: 'item_type', id: deviceBrandModel.id },
            name: 'Samsung',
            position: '2'
          }),
          client.items.create({
            item_type: { type: 'item_type', id: deviceBrandModel.id },
            name: 'ZTE',
            position: '3',
          }),
        ]);
    
  • Temporarily change the model sort type to not be manual sorting (and enable it again after all the records are created)
  • Creating those records sequentially rather than in parallel (will be slower though)

Sorry about that! I’ll let you know once it’s fixed.