Open
Description
Describe the bug
When using custom document actions to extend the publish action, sometimes the document is not published.
It doesn't happen in a specific pattern, but more at random. Looking in the network tab, the POST
publish call is not sent when this happens. When it manages to publish, the POST
is sent. There is no error in the console.
To Reproduce
Steps to reproduce the behavior:
- Implement extension of document action
export function publishAction(originalAction, context) {
const BetterAction = (props) => {
const { patch } = useDocumentOperation(props.id, props.type);
const originalResult = originalAction(props);
return {
...originalResult,
onHandle: async () => {
if (props.draft.publishedAt === undefined) {
patch.execute([{ set: { publishedAt: new Date().toISOString() } }]);
}
patch.execute([{ set: { lastPublishedAt: new Date().toISOString() } }]);
originalResult.onHandle();
},
};
};
return BetterAction;
}
- Add it to
sanity.config.ts
...
prev.map((originalAction) => {
if (originalAction.action === "publish") {
return publishAction(originalAction, context);
}
...
- Try publishing a document in Sanity Studio, sometimes it doesn't get published (after 5-6 times perhaps, and sometimes straight away)
Screenshots
publish-sanity-bug.mov
Which versions of Sanity are you using?
❯ sanity versions
@sanity/cli (global) 3.46.0 (latest: 3.75.0)
@sanity/dashboard 4.1.2 (up to date)
@sanity/eslint-config-studio 5.0.1 (up to date)
@sanity/icons 3.5.7 (up to date)
@sanity/types 3.75.0 (up to date)
@sanity/ui 2.12.3 (latest: 2.12.4)
@sanity/vision 3.75.0 (up to date)
sanity 3.75.0 (up to date)
What operating system are you using?
MacOS. Also experiencing this on our deployed studio
Which versions of Node.js / npm are you running?
❯ npm -v && node -v
10.7.0
v22.2.0
Additional context
I have tried the different examples in custom document actions with no luck.
Metadata
Assignees
Labels
No labels
Activity