Skip to content

Commit 267c236

Browse files
authored
fix(ui): global documents disabled after save (#6652)
1 parent 19f8cbc commit 267c236

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

packages/ui/src/providers/DocumentInfo/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,12 +354,14 @@ export const DocumentInfoProvider: React.FC<
354354

355355
const docPreferences = await getDocPreferences()
356356

357+
const newData = collectionSlug ? json.doc : json.result
358+
357359
const newState = await getFormState({
358360
apiRoute: api,
359361
body: {
360362
id,
361363
collectionSlug,
362-
data: json.doc,
364+
data: newData,
363365
docPreferences,
364366
globalSlug,
365367
locale,
@@ -369,8 +371,6 @@ export const DocumentInfoProvider: React.FC<
369371
serverURL,
370372
})
371373

372-
const newData = json.doc
373-
374374
setInitialState(newState)
375375
setData(newData)
376376
await getDocPermissions(newData)

test/admin/e2e/1/e2e.spec.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ describe('admin1', () => {
6969
let page: Page
7070
let geoUrl: AdminUrlUtil
7171
let postsUrl: AdminUrlUtil
72+
let globalURL: AdminUrlUtil
7273
let customViewsURL: AdminUrlUtil
7374
let disableDuplicateURL: AdminUrlUtil
7475
let serverURL: string
@@ -87,6 +88,7 @@ describe('admin1', () => {
8788
}))
8889
geoUrl = new AdminUrlUtil(serverURL, geoCollectionSlug)
8990
postsUrl = new AdminUrlUtil(serverURL, postsCollectionSlug)
91+
globalURL = new AdminUrlUtil(serverURL, globalSlug)
9092
customViewsURL = new AdminUrlUtil(serverURL, customViews2CollectionSlug)
9193
disableDuplicateURL = new AdminUrlUtil(serverURL, disableDuplicateSlug)
9294

@@ -616,6 +618,22 @@ describe('admin1', () => {
616618
})
617619
})
618620

621+
describe('form state', () => {
622+
test('collection — should re-enable fields after save', async () => {
623+
await page.goto(postsUrl.create)
624+
await page.locator('#field-title').fill(title)
625+
await saveDocAndAssert(page)
626+
await expect(page.locator('#field-title')).toBeEnabled()
627+
})
628+
629+
test('global — should re-enable fields after save', async () => {
630+
await page.goto(globalURL.global(globalSlug))
631+
await page.locator('#field-title').fill(title)
632+
await saveDocAndAssert(page)
633+
await expect(page.locator('#field-title')).toBeEnabled()
634+
})
635+
})
636+
619637
describe('document titles', () => {
620638
test('collection — should render fallback titles when creating new', async () => {
621639
await page.goto(postsUrl.create)
@@ -647,15 +665,19 @@ describe('admin1', () => {
647665
})
648666

649667
test('global — should render custom, localized label', async () => {
650-
await page.goto(postsUrl.admin)
651-
await page.waitForURL(postsUrl.admin)
668+
await page.goto(globalURL.global(globalSlug))
669+
await page.waitForURL(globalURL.global(globalSlug))
652670
await openNav(page)
653671
const label = 'My Global Label'
654672
const globalLabel = page.locator(`#nav-global-global`)
655673
await expect(globalLabel).toContainText(label)
656674
await globalLabel.click()
657675
await checkPageTitle(page, label)
658676
await checkBreadcrumb(page, label)
677+
await page.locator('#field-title').fill(title)
678+
await saveDocAndAssert(page)
679+
await checkPageTitle(page, label)
680+
await checkBreadcrumb(page, label)
659681
})
660682

661683
test('global — should render simple label strings', async () => {

0 commit comments

Comments
 (0)