Skip to content

Commit

Permalink
fix: only replace the drawer content with full edit component if it e…
Browse files Browse the repository at this point in the history
…xists (#5144)
  • Loading branch information
JarrodMFlesch committed Feb 21, 2024
1 parent 3918fc7 commit 0a07f60
Showing 1 changed file with 3 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,9 @@ const Content: React.FC<DocumentDrawerProps> = ({

const { id, docPermissions, getDocPreferences } = useDocumentInfo()

// The component definition could come from multiple places in the config
// we need to cascade into the proper component from the top-down
// 1. "components.Edit"
// 2. "components.Edit.Default"
// 3. "components.Edit.Default.Component"
const CustomEditView =
typeof Edit === 'function'
? Edit
: typeof Edit === 'object' && typeof Edit.Default === 'function'
? Edit.Default
: typeof Edit?.Default === 'object' &&
'Component' in Edit.Default &&
typeof Edit.Default.Component === 'function'
? Edit.Default.Component
: undefined
// If they are replacing the entire edit view, use that.
// Else let the DefaultEdit determine what to render.
const CustomEditView = typeof Edit === 'function' ? Edit : undefined

const [fields, setFields] = useState(() => formatFields(collectionConfig, true))

Expand Down

0 comments on commit 0a07f60

Please sign in to comment.