-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Open
Labels
created-by: Contributorplugin: richtext-lexical@payloadcms/richtext-lexical@payloadcms/richtext-lexical
Description
Describe the Bug
When two different editors use the same TextStateFeature config:

We get client-side error:
Lexical.dev.mjs:20 Uncaught Error: $setState: State key collision "color" detected in TextNode node with type text and key 18. Only one StateConfig with a given key should be used on a node.
at StatePlugin.useEffect (textState.ts:62:40)
at Map.forEach (<anonymous>)
at StatePlugin.useEffect (textState.ts:61:20)
at StatePlugin.useEffect (textState.ts:46:31)
Link to the code that reproduces this issue
https://github.com/elliott-w/payload/tree/bug-text-collision
Reproduction Steps
Here's the editor config:
import {
BlocksFeature,
InlineToolbarFeature,
lexicalEditor,
TextStateFeature,
} from '@payloadcms/richtext-lexical'
import { type Block } from 'payload'
const CustomTextStateFeature = TextStateFeature({
state: {
color: {
red: {
label: 'Red',
css: {
color: 'red',
},
},
},
},
})
const testBlockEditor = lexicalEditor({
features: [CustomTextStateFeature, InlineToolbarFeature()],
})
const TestBlock: Block = {
slug: 'testBlock',
fields: [
{
name: 'contentNested',
type: 'richText',
editor: testBlockEditor,
},
],
}
export const fullEditor = lexicalEditor({
features: [
CustomTextStateFeature,
InlineToolbarFeature(),
BlocksFeature({
blocks: [TestBlock],
}),
],
})
Which area(s) are affected? (Select all that apply)
plugin: richtext-lexical
Environment Info
Binaries:
Node: 23.11.0
npm: 10.9.2
Yarn: N/A
pnpm: 9.7.1
Relevant Packages:
payload: 3.54.0
next: 15.4.4
@payloadcms/db-postgres: 3.54.0
@payloadcms/live-preview-react: 3.54.0
react: 19.1.0
react-dom: 19.1.0
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:40 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T8132
Available memory (MB): 16384
Available CPU cores: 10
Metadata
Metadata
Assignees
Labels
created-by: Contributorplugin: richtext-lexical@payloadcms/richtext-lexical@payloadcms/richtext-lexical