Skip to content

fix(ui): strip lastRenderedPath from copied form state so pasted rows re-render - #17716

Open
1yakub wants to merge 2 commits into
payloadcms:mainfrom
1yakub:fix/clipboard-strip-last-rendered-path
Open

fix(ui): strip lastRenderedPath from copied form state so pasted rows re-render#17716
1yakub wants to merge 2 commits into
payloadcms:mainfrom
1yakub:fix/clipboard-strip-last-rendered-path

Conversation

@1yakub

@1yakub 1yakub commented Aug 7, 2026

Copy link
Copy Markdown

Fixes #17375

When you copy a blocks row and paste it onto the same field path and row index, the block body goes blank until a full page refresh. The data is intact, it's purely a render bug.

@DarioSiroki traced the root cause in the issue and this PR follows his suggested fix, so full credit for the diagnosis goes to him. In short: reduceFormStateByPath strips customComponents from the copied form state because it isn't serializable, but it keeps lastRenderedPath. On paste the server checks lastRenderedPath !== path to decide whether a field needs rendering, and since the pasted entries carry the stale value from the clipboard, a same path paste looks already rendered and never gets its components back. The client falls back to return null, so the whole block body disappears.

The fix strips lastRenderedPath at copy time, both at field level and on row entries, right next to the existing customComponents stripping. Pasted content then renders again on the next form state round trip. As Dario notes in the issue, the trade off is that array pastes get one redundant server render even though their customComponents survive the merge.

Added two unit tests in mergeFormStateFromClipboard.spec.ts covering field level and row level stripping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pasting a copied blocks row renders the block blank until page refresh

1 participant