Skip to content

lexical editor can not update by useField hook #12835

@leenchan

Description

@leenchan

Describe the Bug

`import { useField, Button } from '@payloadcms/ui'

const Button = () => {
const { value, setValue } = useField({ path: 'content' })

const onClick = () => {
setValue({
root: {...}
})
}

return (
Set
)
}`

Link to the code that reproduces this issue

https://github.com/payloadcms/payload/blob/53835f26/docs/admin/react-hooks.mdx

Reproduction Steps

after the button is clicked, the new value is stored in DB, but lexical editor does not change (update), need to refresh browser page

Which area(s) are affected? (Select all that apply)

db-mongodb, plugin: richtext-lexical

Environment Info

Binaries:
  Node: 21.2.0
  npm: 10.2.3
  Yarn: 1.22.22
  pnpm: 10.3.0
Relevant Packages:
  payload: 3.42.0
  next: 15.3.3
  @payloadcms/db-mongodb: 3.42.0
  @payloadcms/email-nodemailer: 3.42.0
  @payloadcms/graphql: 3.42.0
  @payloadcms/live-preview: 3.42.0
  @payloadcms/live-preview-react: 3.42.0
  @payloadcms/next/utilities: 3.42.0
  @payloadcms/payload-cloud: 3.42.0
  @payloadcms/plugin-form-builder: 3.42.0
  @payloadcms/plugin-nested-docs: 3.42.0
  @payloadcms/plugin-redirects: 3.42.0
  @payloadcms/plugin-search: 3.42.0
  @payloadcms/plugin-seo: 3.42.0
  @payloadcms/richtext-lexical: 3.42.0
  @payloadcms/translations: 3.42.0
  @payloadcms/ui/shared: 3.42.0
  react: 19.1.0
  react-dom: 19.1.0
Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Tue, 10 Jun 2025 21:32:33 +0000
  Available memory (MB): 47896
  Available CPU cores: 16

Metadata

Metadata

Assignees

Labels

area: docsImprovements or additions to documentationplugin: richtext-lexical@payloadcms/richtext-lexical

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions