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
24.39k stars 1.54k forks source link

Bug Report: openModal is not a function error when adding a link in the RichText Slate editor #8576

Open JM-JKISOL opened 1 week ago

JM-JKISOL commented 1 week ago

Description: I am encountering an issue with the RichText editor (@payloadcms/richtext-slate package, version 1.5.2) while using it in a Next.js project. When trying to add a link in the editor, the modal to input the link does not show, and I receive the following error in the browser console:

Uncaught (in promise) TypeError: openModal is not a function

Environment: @payloadcms/richtext-slate: 1.5.2 Next.js: 13.5.2 npm: 10.7.0 Node.js: 20.15.0

Steps to Reproduce:

  1. Install @payloadcms/richtext-slate using npm i @payloadcms/richtext-slate.
  2. Implement the RichText editor in a Next.js project.
  3. Attempt to add a link using the RichText editor.
  4. Observe that the link modal does not appear.
  5. Check the console for the error: Uncaught (in promise) TypeError: openModal is not a function.

Expected Behavior: The modal to input the link should appear when attempting to add a link using the RichText Slate editor.

Actual Behavior: The link modal does not appear, and the following error is logged in the console:

Uncaught (in promise) TypeError: openModal is not a function

Additional Information: I am using the RichText Slate editor in a Next.js project. Please let me know if more information is needed or if there's a workaround for this issue.

tijsomnicasa commented 1 week ago

I'm having the same error payload@2.30.1 @payloadcms/richtext-slate@1.5.2

dbambulaks commented 1 week ago

Have you tried to strict downgrade to payload@2.30.0? Looks like 'use client' directive is introduced in @faceless-ui/modal@2.0.2 which could be the case for the issues, we have something similar happening....

tijsomnicasa commented 1 week ago

@dbambulaks I can confirm this solves the problem! Thank you very much for your input!

Just as an FYI for devs, the same error occurs in the lexical editor for payload@2.30.1