Skip to content

fix(ui): call useQueue's beforeProcess before every task, so autosave keeps edits made during a queued save - #18350

Closed
adrian-baker wants to merge 1 commit into
payloadcms:3.xfrom
adrian-baker:fix/use-queue-before-process-3.x
Closed

adrian-baker wants to merge 1 commit into
payloadcms:3.xfrom
adrian-baker:fix/use-queue-before-process-3.x

Conversation

@adrian-baker

Copy link
Copy Markdown

What?

useQueue now calls beforeProcess before each task it runs, instead of once before its loop. afterProcess already runs after each task, so the two now pair up for every task. This is the 3.x counterpart of #18349, with the same change.

Why?

Autosave uses the two callbacks to set the form's background processing flag on and off. When a second autosave was queued behind the first, it ran after afterProcess had turned the flag off, and nothing turned it back on. An edit made during that save then wasn't recorded as "modified while processing", the save's response reset modified to false, and the autosave for that edit found nothing to save. The editor's last edit was lost, although the field showed it. Fixes #18348, which has the full sequence.

How?

The beforeProcess check moves to the top of the while loop. Returning false still stops processing and leaves the queue as it was, as it did before the loop. The doc comment on beforeProcess says it's called before each function.

3.x has no browser test project for a hook test, so this PR has no spec. #18349 adds useQueue.spec.tsx on main, where the first test fails without the change. On 3.90.2, a Playwright run that holds each autosave request lost the last edit on every run without the change, and kept it on every run with it.

🤖 Generated with Claude Code

afterProcess already runs after every task, so a task queued behind another ran after afterProcess and without a beforeProcess of its own. Autosave uses the pair to set the form's background processing flag, so an edit made during a queued autosave wasn't recorded as modified while processing, and the autosave for that edit was skipped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jacobsfletch

Copy link
Copy Markdown
Member

See my comment here: #18349 (comment)

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants