Skip to content

Commit b95df0b

Browse files
authored
fix(ui): document status shows changed after publishing specific locale (#15765)
### What? When `localizeStatus` is enabled and `defaultLocalePublishOption` is set to `active`, publishing a specific locale leaves the document status showing "Changed" instead of "Published" until the page is refreshed. ### Why? The `publishSpecificLocale` callback in `PublishButton` only called `setHasPublishedDoc(true)` on success, but did not reset `unpublishedVersionCount` or `mostRecentVersionIsAutosaved`. The `Status` component uses `unpublishedVersionCount > 0 && hasPublishedDoc` to render "Changed", so the stale count kept the status incorrect. The `publish` (all locales) callback already handled this correctly, `publishSpecificLocale` was just missing the same state resets. ### How? Added `setUnpublishedVersionCount(0)` and `setMostRecentVersionIsAutosaved(false)` to the `publishSpecificLocale` success handler, matching what `publish` already does. Added an e2e test that reproduces the issue.
1 parent b97b4e7 commit b95df0b

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

packages/ui/src/elements/PublishButton/index.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,22 @@ export function PublishButton({
235235
})
236236

237237
if (result) {
238+
setUnpublishedVersionCount(0)
239+
setMostRecentVersionIsAutosaved(false)
238240
setHasPublishedDoc(true)
239241
}
240242
},
241-
[api, collectionSlug, globalSlug, id, setHasPublishedDoc, submit, uploadStatus],
243+
[
244+
api,
245+
collectionSlug,
246+
globalSlug,
247+
id,
248+
setHasPublishedDoc,
249+
setMostRecentVersionIsAutosaved,
250+
setUnpublishedVersionCount,
251+
submit,
252+
uploadStatus,
253+
],
242254
)
243255

244256
// Publish to all locales unless there are localized fields AND defaultLocalePublishOption is 'active'

test/admin/e2e/document-view/e2e.spec.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,26 @@ describe('Document View', () => {
746746
await expect(publishButton).toContainText('Publish changes')
747747
await expect(publishButton).not.toContainText('Publish in')
748748
})
749+
750+
test('should show published status after publishing specific locale', async () => {
751+
await page.goto(localizedURL.create)
752+
const status = page.locator('.status__value')
753+
754+
await page.locator('#field-title').fill('Published title')
755+
await saveDocAndAssert(page)
756+
757+
await expect(status).toContainText('Published')
758+
759+
await page.locator('#field-title').fill('Draft change')
760+
await saveDocAndAssert(page, '#action-save-draft')
761+
762+
await expect(status).toContainText('Changed')
763+
764+
await page.locator('#field-title').fill('Published again')
765+
await saveDocAndAssert(page)
766+
767+
await expect(status).toContainText('Published')
768+
})
749769
})
750770

751771
describe('reserved field names', () => {

0 commit comments

Comments
 (0)