Skip to content

fix(ui): prevent stale upload docs from overwriting value - #17735

Open
ertugakmann wants to merge 1 commit into
payloadcms:mainfrom
ertugakmann:fix/lexical-upload-field-state
Open

fix(ui): prevent stale upload docs from overwriting value#17735
ertugakmann wants to merge 1 commit into
payloadcms:mainfrom
ertugakmann:fix/lexical-upload-field-state

Conversation

@ertugakmann

Copy link
Copy Markdown

What?

Fixes a race condition in the Upload field where an older populateDocs() request can overwrite the state of a newer field value.

Why?

When upload values change while a previous populateDocs() request is still in flight, the older request can resolve later and replace populatedDocs with stale data.

This can cause upload values to disappear, particularly in hasMany upload fields inside Lexical blocks.

How?

Track the latest field value with a ref and only apply populateDocs() results if they still match the current value.

Added a regression test covering out-of-order requests and a test for the normal in-order case.

Fixes #17731

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.

Upload field values inside Lexical block forms are replaced, not appended, when the list drawer cycles (minRows error also does not block publish)

1 participant