payloadcms / payload

Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
https://payloadcms.com
MIT License
25.73k stars 1.64k forks source link

Error when editing link in lexical #8802

Closed udany closed 4 weeks ago

udany commented 4 weeks ago

Link to reproduction

No response

Describe the Bug

When clicking the edit button on a link in lexical the following error happens:

Uncaught TypeError: toggleModal is not a function
    at onClick (index.tsx:307:19)
    at HTMLUnknownElement.callCallback (react-dom.development.js:4164:14)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:4213:16)
    at invokeGuardedCallback (react-dom.development.js:4277:31)
    at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4291:25)
    at executeDispatch (react-dom.development.js:9041:3)
    at processDispatchQueueItemsInOrder (react-dom.development.js:9073:7)
    at processDispatchQueue (react-dom.development.js:9086:5)
    at dispatchEventsForPlugins (react-dom.development.js:9097:3)
    at react-dom.development.js:9288:12

The error points to the fact toggleModal is undefined when called.

Debugging in devtools I found out useModal is returning {}.

To Reproduce

It's a relatively fresh project, started with npx create-payload-app@latest and added @payloadcms/richtext-lexical

Here's my payload config:

export default buildConfig({
    admin: {
        user: Users.slug,
        bundler: webpackBundler(),
        meta: {
            favicon: '/public/favicon.png'
        },
        dateFormat: 'dd/MM/yyyy HH:mm:ss',
    },
    editor: lexicalEditor(),
    collections: [
        Users, Articles, Media
    ],
    typescript: {
        outputFile: path.resolve(__dirname, 'payload-types.ts'),
    },
    graphQL: {
        schemaOutputFile: path.resolve(__dirname, 'generated-schema.graphql'),
    },
    plugins: [payloadCloud(), addLastModified],
    db: postgresAdapter({
        pool: {
            connectionString: process.env.DATABASE_URI,

        },
    })
})
  "dependencies": {
    "@payloadcms/bundler-vite": "^0.1.7",
    "@payloadcms/bundler-webpack": "^1.0.0",
    "@payloadcms/db-postgres": "^0.x",
    "@payloadcms/plugin-cloud": "^3.0.0",
    "@payloadcms/richtext-lexical": "^0.11.3",
    "cross-env": "^7.0.3",
    "dotenv": "^8.2.0",
    "express": "^4.19.2",
    "payload": "^2.0.0"
  },

Payload Version

2.0.0

Adapters and Plugins

db-postgres, bundler-webpack,

udany commented 4 weeks ago

Updating to ^0.11.4 magically fixed it

github-actions[bot] commented 3 weeks ago

This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.