Skip to content

Commit 35f7a9e

Browse files
authored
fix(richtext-lexical): newly created upload nodes with extra fields do not display fields when opening extra fields drawer (#7155)
Fixes #7128
1 parent a4c7fdd commit 35f7a9e

File tree

4 files changed

+6
-9
lines changed

4 files changed

+6
-9
lines changed

packages/richtext-lexical/src/features/experimental_table/plugins/TablePlugin/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ export const TablePlugin: PluginComponent = () => {
117117
return (
118118
<React.Fragment>
119119
<FieldsDrawer
120-
data={{}}
121120
drawerSlug={drawerSlug}
122121
drawerTitle="Create Table"
123122
featureKey="experimental_table"

packages/richtext-lexical/src/features/link/plugins/floatingLinkEditor/LinkEditor/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function LinkEditor({ anchorElem }: { anchorElem: HTMLElement }): React.R
4242

4343
const { i18n, t } = useTranslation()
4444

45-
const [stateData, setStateData] = useState<({ id?: string; text: string } & LinkFields) | {}>({})
45+
const [stateData, setStateData] = useState<{ id?: string; text: string } & LinkFields>(null)
4646

4747
const { closeModal, toggleModal } = useModal()
4848
const editDepth = useEditDepth()
@@ -66,7 +66,7 @@ export function LinkEditor({ anchorElem }: { anchorElem: HTMLElement }): React.R
6666
setLinkUrl(null)
6767
setLinkLabel(null)
6868
setSelectedNodes([])
69-
setStateData({})
69+
setStateData(null)
7070
}, [setIsLink, setLinkUrl, setLinkLabel, setSelectedNodes])
7171

7272
const $updateLinkEditor = useCallback(() => {

packages/richtext-lexical/src/utilities/fieldsDrawer/Drawer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use client'
2-
import type { FormState } from 'payload'
2+
import type { Data, FormState } from 'payload'
33

44
import { Drawer } from '@payloadcms/ui'
55
import React from 'react'
@@ -8,7 +8,7 @@ import { DrawerContent } from './DrawerContent.js'
88

99
export type FieldsDrawerProps = {
1010
className?: string
11-
data: any
11+
data?: Data
1212
drawerSlug: string
1313
drawerTitle?: string
1414
featureKey: string

packages/richtext-lexical/src/utilities/fieldsDrawer/DrawerContent.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const DrawerContent: React.FC<Omit<FieldsDrawerProps, 'drawerSlug' | 'dra
4545
apiRoute: config.routes.api,
4646
body: {
4747
id,
48-
data,
48+
data: data ?? {},
4949
operation: 'update',
5050
schemaPath: schemaFieldsPath,
5151
},
@@ -55,9 +55,7 @@ export const DrawerContent: React.FC<Omit<FieldsDrawerProps, 'drawerSlug' | 'dra
5555
setInitialState(state)
5656
}
5757

58-
if (data) {
59-
void awaitInitialState()
60-
}
58+
void awaitInitialState()
6159
}, [config.routes.api, config.serverURL, schemaFieldsPath, id, data])
6260

6361
const onChange: FormProps['onChange'][0] = useCallback(

0 commit comments

Comments
 (0)