Open giovanni-caiazzo opened 2 years ago
Hi, I encountered the same issue with basically the same use case. After some debugging I tracked down the issue to the ids of the respective ConnectedRichTextEditor
s. Internally they are passed to the Plate
component, which requires the ids to be unique. I was able to fix the issue by passing a unique id to our custom ConnectedRichTextEditor
implementation which replaces the internal id calculation.
Unfortunately there doesn't seem to be a fix available without rewriting the internal rich text editor logic.
Thank you so much @niclaszllaudi for pinpointing the issue in the codebase. I have used patch-package
to make it work. This however is NOT a solution to the issue and if the devs want us to make a PR I would happily do it. For now my project is not blocked though, which is great.
I was able to fix the issue by passing a unique id to our custom ConnectedRichTextEditor implementation which replaces the internal id calculation.
Can you share more about your use case @niclaszllaudi & @giovanni-caiazzo ?
For the internal ids calculation we use the entry key + field id + the locale code. So, in theory, it should only clash if you are rendering the same entry field for the same locale twice. Is that the case for you?
Hi @z0al. In my use case I have a contentful app that is rendering a json field as a collection of rich text fields, each accessible with its own tab. I used patch-package to add a new prop to ConnectedRichEditor in order to add a custom ID appended to the ID you are creating like you described.
Hi @z0al, we want to render two ConnectedRichTextEditor
instances within the same field. This results in both being assigned the same id, causing the issue.
Marking issue as stale since there was no acitivty for 30 days
Hi all, I am using @contentful/field-editor-rich-text in a contentful app, version 2.1.0 and I have some problems with rerendering. Basically I am rendering a set of tabs and each tab has an instance of @contentful/field-editor-rich-text:
When the component first renders it works great, but as soon as I change tab, the editor disappears and never reappears even when I return to the original tab. When the page is reloaded the editor reappears, only to disappear again as soon as a new tab is selected. I also tried to render all the editors together without tabs: what happens is that all the editors have the content of the last rendered editor, which is not ideal.
Here is the full Field component
Is there something I'm doing wrong when rendering the editors? Or is this a bug of the editor? Version 1 did not have this problem using the same code structure, but it did have problems selecting the text and changing it.