Repository navigation
fix(ui): show the hook error when reordering fails - #18579
Open
MustafaKemal0146 wants to merge 1 commit into
Open
MustafaKemal0146 wants to merge 1 commit into
MustafaKemal0146 wants to merge 1 commit into
Conversation
When a hook throws an APIError while rows are reordered in the list view, the toast always showed the generic "Failed to reorder" message instead of the error from the hook. Read the error message from the response of the reorder endpoint and show it. Internal server errors are masked by the server, so they and responses without an error message keep the generic retry message. Fixes payloadcms#16308 Co-Authored-By: Claude Opus 5.5 <[email protected]>
MustafaKemal0146
requested review from
AlessioGr,
JarrodMFlesch and
jacobsfletch
as code owners
October 7, 2026 07:35
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
When a collection hook throws an
APIErrorwhile rows are reordered in the list view (orderable: true), the toast now shows the hook's error message. Before, it always showed the generic "Failed to reorder. This can happen if you reorder several rows too quickly. Please try again."Why?
The reorder endpoint already passes
APIErrors from hooks through to the response, butOrderableTableignored the response body for every non-OK status. Editors could not see why a reorder was rejected (for example a validation or locking rule in abeforeChangehook).How?
getReorderErrorMessageinpackages/ui/src/elements/Table/. It returnserrors[0].messagefrom the response body.errorsarray (the endpoint's own 400 responses use{ error });OrderableTablethrows with that message, so the existingtoast.errorand rollback are unchanged. The 403 branch is unchanged.Tests:
getReorderErrorMessage.spec.ts(4 cases).orderable-hook-errorcollection intest/sortwith abeforeChangehook that throwsAPIError(..., 400)on reorder. The test drags a row and expects the hook message in the error toast and the rows rolled back. It fails onmain(toast shows "Failed to reorder…") and passes with this change.PAYLOAD_DATABASE=sqlite pnpm test:e2e sort(3 passed),PAYLOAD_DATABASE=sqlite pnpm test:int sort(44 passed), the unit test,eslintandprettier.test/sort/payload-types.ts: I added only the types for the new collection. The committed file was already behind the generator in unrelated places, which I left alone.Accessibility (payload-accessibility skill):
toast.errorcall and live region) are unchanged.Also applies to
3.x(same code inOrderableTable.tsx).Fixes #16308
AI-assisted: prepared with Claude Code and reviewed by me.
🤖 Generated with Claude Code