@@ -21,7 +21,7 @@ import { RenderTitle } from '../RenderTitle/index.js'
21
21
import { baseClass } from './index.js'
22
22
23
23
export const DocumentDrawerContent : React . FC < DocumentDrawerProps > = ( {
24
- id,
24
+ id : existingDocID ,
25
25
Header,
26
26
collectionSlug,
27
27
drawerSlug,
@@ -39,7 +39,7 @@ export const DocumentDrawerContent: React.FC<DocumentDrawerProps> = ({
39
39
const { closeModal, modalState, toggleModal } = useModal ( )
40
40
const locale = useLocale ( )
41
41
const { t } = useTranslation ( )
42
- const [ createdID , setCreatedID ] = useState ( )
42
+ const [ docID , setDocID ] = useState ( existingDocID )
43
43
const [ isOpen , setIsOpen ] = useState ( false )
44
44
const [ collectionConfig ] = useRelatedCollections ( collectionSlug )
45
45
const { formQueryParams } = useFormQueryParams ( )
@@ -48,10 +48,12 @@ export const DocumentDrawerContent: React.FC<DocumentDrawerProps> = ({
48
48
const { componentMap } = useComponentMap ( )
49
49
50
50
const { Edit } = componentMap [ `${ collectionSlug ? 'collections' : 'globals' } ` ] [ collectionSlug ]
51
- const isEditing = Boolean ( id )
52
- const apiURL = id ? `${ serverURL } ${ apiRoute } /${ collectionSlug } /${ id } ?locale=${ locale . code } ` : null
51
+ const isEditing = Boolean ( docID )
52
+ const apiURL = docID
53
+ ? `${ serverURL } ${ apiRoute } /${ collectionSlug } /${ docID } ?locale=${ locale . code } `
54
+ : null
53
55
const action = `${ serverURL } ${ apiRoute } /${ collectionSlug } ${
54
- isEditing ? `/${ id } ` : ''
56
+ isEditing ? `/${ docID } ` : ''
55
57
} ?${ formattedQueryParams } `
56
58
57
59
useEffect ( ( ) => {
@@ -70,7 +72,7 @@ export const DocumentDrawerContent: React.FC<DocumentDrawerProps> = ({
70
72
71
73
const onSave = useCallback < DocumentDrawerProps [ 'onSave' ] > (
72
74
( args ) => {
73
- setCreatedID ( args . doc . id )
75
+ setDocID ( args . doc . id )
74
76
if ( typeof onSaveFromProps === 'function' ) {
75
77
void onSaveFromProps ( {
76
78
...args ,
@@ -115,7 +117,7 @@ export const DocumentDrawerContent: React.FC<DocumentDrawerProps> = ({
115
117
// Same reason as above. We need to fully-fetch the docPreferences from the server. This is done in DocumentInfoProvider if we set it to null here.
116
118
hasSavePermission = { null }
117
119
// isLoading,
118
- id = { id || createdID }
120
+ id = { docID }
119
121
isEditing = { isEditing }
120
122
onLoadError = { onLoadError }
121
123
onSave = { onSave }
0 commit comments