Fixes #12975. When editing autosave-enabled documents through the join field, the document drawer closes unexpectedly on every autosave interval, making it nearly impossible to use. This is because as of #12842, the underlying relationship table re-renders on every autosave event, remounting the drawer each time. The fix is to lift the drawer out of table's rendering tree and into the join field itself. This way all rows share the same drawer, whose rendering lifecycle has been completely decoupled from the table's state. Note: this is very similar to how relationship fields achieve similar functionality. This PR also adds jsdocs to the `useDocumentDrawer` hook and strengthens its types. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1210906078627353
33 lines
666 B
TypeScript
33 lines
666 B
TypeScript
import type { CollectionConfig } from 'payload'
|
|
|
|
import { categoriesVersionsSlug, versionsSlug } from '../shared.js'
|
|
|
|
export const CategoriesVersions: CollectionConfig = {
|
|
slug: categoriesVersionsSlug,
|
|
labels: {
|
|
singular: 'Category With Versions',
|
|
plural: 'Categories With Versions',
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'title',
|
|
type: 'text',
|
|
},
|
|
{
|
|
name: 'relatedVersions',
|
|
type: 'join',
|
|
collection: versionsSlug,
|
|
on: 'categoryVersion',
|
|
},
|
|
{
|
|
name: 'relatedVersionsMany',
|
|
type: 'join',
|
|
collection: versionsSlug,
|
|
on: 'categoryVersions',
|
|
},
|
|
],
|
|
versions: {
|
|
drafts: true,
|
|
},
|
|
}
|