You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
reordering blocks using a beforeChange hook mixes up block types in the admin UI and can lead to corrupted documents #12368
I have a use case where I need to reorder blocks based on dates using a beforeChange hook.
However when reordering the blocks the UI seem to mix up blocks types and contents.
In the reproduction repo I have setup a very simple Pages example that sorts blocks in descending order and can reproduce the main issue.
In a more complex example I have managed to corrupt blocks data after the third save with an incorrect state in the admin UI.
pnpm install && pnpm dev
create .env file using .env.example
create admin account
create and save an empty page, then follow instructions to add blocks
Add block one, title "one" order "1", save the Page document
Add block two, title "two" order "2", save the page document
The blocks are saved but the admin UI is confused between blocks types (ie : block 01 is of type one but has block two contents)
Adding block `three, title "three" order "3" etc will continue producing the same bug.
Which area(s) are affected? (Select all that apply)
this is the Pages collection config in the reproduction repo
importtype{CollectionConfig,Field}from'payload'constblockFields: Field[]=[{name: 'title',type: 'text',},{name: 'order',type: 'number',},]exportconstPages: CollectionConfig={slug: 'pages',fields: [{name: 'blocks',label: false,type: 'blocks',admin: {initCollapsed: true,// Collapse the blocks by defaultisSortable: true,// we'll try to sort the blocks by date on save once the bug is resolved},hooks: {beforeChange: [({ value })=>{returnvalue.sort((a,b)=>{returnb.order-a.order})},],},blocks: [{slug: 'one',fields: blockFields,},{slug: 'two',fields: blockFields,},{slug: 'three',fields: blockFields,},{slug: 'four',fields: blockFields,},],},],}
Hi. I've updated to the latest payload version (3.40.0) and unfortunately the issue is still present.
I've bumped the packages in the reproduction repo as well.
Is there any way I can help diagnose this issue further ? Thank you.
Activity
ioExpander commentedon May 9, 2025
this is the Pages collection config in the reproduction repo
ioExpander commentedon Jun 4, 2025
Hi. I've updated to the latest payload version (3.40.0) and unfortunately the issue is still present.
I've bumped the packages in the reproduction repo as well.
Is there any way I can help diagnose this issue further ? Thank you.
JessRynkar commentedon Jan 20, 2026
Hi! Apologies for the long delay in getting a response here, are you still experiencing this on the latest version
v3.72.0?ioExpander commentedon Jan 20, 2026
Hi @JessRynkar . thank you for looking into this.
Yes the issue is still present in v3.72.0. I've updated the repro repo as well.
JessRynkar commentedon Jan 20, 2026
Thank you for confirming, we'll get someone assigned to this.
fix(ui): preserve array and block data after server-side reordering (#…
github-actions commentedon Nov 20, 2026
🚀 This is included in version v4.0.0-beta.11
fix(ui): prevent stale responses from overwriting form state (#17455)