fix(richtext-lexical): richtext field duplicates description custom component (#13880)
The lexical field component was accidentally rendering the description component twice. Fixes https://github.com/payloadcms/payload/issues/13644
This commit is contained in:
@@ -184,7 +184,6 @@ const RichTextComponent: React.FC<
|
|||||||
/>
|
/>
|
||||||
{AfterInput}
|
{AfterInput}
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
{Description}
|
|
||||||
<RenderCustomComponent
|
<RenderCustomComponent
|
||||||
CustomComponent={Description}
|
CustomComponent={Description}
|
||||||
Fallback={<FieldDescription description={description} path={path} />}
|
Fallback={<FieldDescription description={description} path={path} />}
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ export const Form: React.FC<FormProps> = (props) => {
|
|||||||
const { startRouteTransition } = useRouteTransition()
|
const { startRouteTransition } = useRouteTransition()
|
||||||
const { getUploadHandler } = useUploadHandlers()
|
const { getUploadHandler } = useUploadHandlers()
|
||||||
|
|
||||||
const { config, getEntityConfig } = useConfig()
|
const { config } = useConfig()
|
||||||
|
|
||||||
const [disabled, setDisabled] = useState(disabledFromProps || false)
|
const [disabled, setDisabled] = useState(disabledFromProps || false)
|
||||||
const [isMounted, setIsMounted] = useState(false)
|
const [isMounted, setIsMounted] = useState(false)
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
export const Description = () => {
|
||||||
|
return (
|
||||||
|
<div className="lexical-blocks-custom-description" style={{ color: 'red' }}>
|
||||||
|
My Custom Lexical Description
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1446,6 +1446,29 @@ describe('lexicalMain', () => {
|
|||||||
page.getByText('Creating new User')
|
page.getByText('Creating new User')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('ensure custom Description component is rendered only once', async () => {
|
||||||
|
await navigateToLexicalFields()
|
||||||
|
const lexicalWithBlocks = page.locator('.rich-text-lexical').nth(2)
|
||||||
|
await lexicalWithBlocks.scrollIntoViewIfNeeded()
|
||||||
|
await expect(lexicalWithBlocks).toBeVisible()
|
||||||
|
|
||||||
|
await expect(lexicalWithBlocks.locator('.lexical-blocks-custom-description')).toHaveCount(1)
|
||||||
|
await expect(lexicalWithBlocks.locator('.lexical-blocks-custom-description')).toBeVisible()
|
||||||
|
|
||||||
|
await expect(lexicalWithBlocks.locator('.field-description')).toHaveCount(0)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('ensure admin.description property is rendered', async () => {
|
||||||
|
await navigateToLexicalFields()
|
||||||
|
const lexicalSimple = page.locator('.rich-text-lexical').nth(1)
|
||||||
|
await lexicalSimple.scrollIntoViewIfNeeded()
|
||||||
|
await expect(lexicalSimple).toBeVisible()
|
||||||
|
|
||||||
|
await expect(lexicalSimple.locator('.field-description')).toHaveCount(1)
|
||||||
|
await expect(lexicalSimple.locator('.field-description')).toBeVisible()
|
||||||
|
await expect(lexicalSimple.locator('.field-description')).toHaveText('A simple lexical field')
|
||||||
|
})
|
||||||
|
|
||||||
test('ensure links can created from clipboard and deleted', async () => {
|
test('ensure links can created from clipboard and deleted', async () => {
|
||||||
await navigateToLexicalFields()
|
await navigateToLexicalFields()
|
||||||
const richTextField = page.locator('.rich-text-lexical').first()
|
const richTextField = page.locator('.rich-text-lexical').first()
|
||||||
|
|||||||
@@ -309,6 +309,9 @@ export const getLexicalFieldsCollection: (args: {
|
|||||||
{
|
{
|
||||||
name: 'lexicalSimple',
|
name: 'lexicalSimple',
|
||||||
type: 'richText',
|
type: 'richText',
|
||||||
|
admin: {
|
||||||
|
description: 'A simple lexical field',
|
||||||
|
},
|
||||||
editor: lexicalEditor({
|
editor: lexicalEditor({
|
||||||
features: ({ defaultFeatures }) => [
|
features: ({ defaultFeatures }) => [
|
||||||
//TestRecorderFeature(),
|
//TestRecorderFeature(),
|
||||||
@@ -347,6 +350,12 @@ export const getLexicalFieldsCollection: (args: {
|
|||||||
{
|
{
|
||||||
name: 'lexicalWithBlocks',
|
name: 'lexicalWithBlocks',
|
||||||
type: 'richText',
|
type: 'richText',
|
||||||
|
admin: {
|
||||||
|
components: {
|
||||||
|
Description: '/collections/Lexical/components/Description.js#Description',
|
||||||
|
},
|
||||||
|
description: 'Should not be rendered',
|
||||||
|
},
|
||||||
editor: lexicalEditor({
|
editor: lexicalEditor({
|
||||||
admin: {
|
admin: {
|
||||||
hideGutter: false,
|
hideGutter: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user