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:
Alessio Gravili
2025-09-22 11:39:55 -07:00
committed by GitHub
parent 228e8f281a
commit 66f5d1429d
5 changed files with 40 additions and 2 deletions

View File

@@ -0,0 +1,7 @@
export const Description = () => {
return (
<div className="lexical-blocks-custom-description" style={{ color: 'red' }}>
My Custom Lexical Description
</div>
)
}

View File

@@ -1446,6 +1446,29 @@ describe('lexicalMain', () => {
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 () => {
await navigateToLexicalFields()
const richTextField = page.locator('.rich-text-lexical').first()

View File

@@ -309,6 +309,9 @@ export const getLexicalFieldsCollection: (args: {
{
name: 'lexicalSimple',
type: 'richText',
admin: {
description: 'A simple lexical field',
},
editor: lexicalEditor({
features: ({ defaultFeatures }) => [
//TestRecorderFeature(),
@@ -347,6 +350,12 @@ export const getLexicalFieldsCollection: (args: {
{
name: 'lexicalWithBlocks',
type: 'richText',
admin: {
components: {
Description: '/collections/Lexical/components/Description.js#Description',
},
description: 'Should not be rendered',
},
editor: lexicalEditor({
admin: {
hideGutter: false,