Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/access-control/collections.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,9 @@ export const CollectionWithVersionsAccess: CollectionConfig = {
```

<Banner type="warning">
**Note:** Returning a [Query](../queries/overview) will apply the constraint to the
[`versions` collection](../versions/overview#database-impact), not the original Collection.
**Note:** Returning a [Query](../queries/overview) will apply the constraint
to the [`versions` collection](../versions/overview#database-impact), not the
original Collection.
</Banner>

The following arguments are provided to the `readVersions` function:
Expand Down
5 changes: 3 additions & 2 deletions docs/access-control/globals.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,9 @@ export const GlobalWithVersionsAccess: GlobalConfig = {
```

<Banner type="warning">
**Note:** Returning a [Query](../queries/overview) will apply the constraint to the
[`versions` collection](../versions/overview#database-impact), not the original Global.
**Note:** Returning a [Query](../queries/overview) will apply the constraint
to the [`versions` collection](../versions/overview#database-impact), not the
original Global.
</Banner>

The following arguments are provided to the `readVersions` function:
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/elements/AddNewRelation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const AddNewRelation: React.FC<Props> = ({
])
} else {
onChange({
relationTo: relatedCollections[0].slug,
relationTo: collectionConfig?.slug,
value: doc.id,
})
}
Expand All @@ -88,7 +88,7 @@ export const AddNewRelation: React.FC<Props> = ({
setSelectedCollection(undefined)
}
},
[collectionConfig, hasMany, onChange, value, relatedCollections],
[collectionConfig, hasMany, onChange, value],
)

const onPopupToggle = useCallback((state) => {
Expand Down
26 changes: 26 additions & 0 deletions test/fields/collections/Relationship/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,32 @@ describe('relationship', () => {
await expect(page.locator('.payload-toast-container')).toContainText('successfully')
})

test('should save correct relationTo when creating doc in second collection (bug #14728)', async () => {
await loadCreatePage()

await openCreateDocDrawer({ page, fieldSelector: '#field-relationship' })

// Select the SECOND collection (array-fields) instead of the first (text-fields)
await page
.locator('#field-relationship .relationship-add-new__relation-button--array-fields')
.click()

await page.locator('[id^=doc-drawer_array-fields_1_] #action-save').click()
await expect(page.locator('.payload-toast-container')).toContainText('successfully')
await page.locator('[id^=close-drawer__doc-drawer_array-fields_1_]').click()

const relationshipValue = page.locator('#field-relationship .relationship--single-value__text')
await expect(relationshipValue).toBeVisible()
await expect(async () => {
const valueText = await relationshipValue.textContent()
expect(valueText).not.toContain('Another text document')
expect(valueText).not.toContain('Untitled')
}).toPass()

await page.locator('#action-save').click()
await expect(page.locator('.payload-toast-container')).toContainText('successfully')
})

test('should create nested inline relationships', async () => {
await loadCreatePage()

Expand Down
Loading