tinymce / tinymce-blazor

Blazor integration
MIT License
45 stars 14 forks source link

Rebuild editor not triggered on re-render #29

Closed Cr3ature closed 2 years ago

Cr3ature commented 2 years ago

Hi,

I have a setup where I have a list of sections. Each section is setup to bind there content to a editor component. When I add or remove a section. The editor values are changed, but the visible value in the editor is not. If I reference the editor, then the editor.Value is changed though.

Example reproduction steps:

The value state has been updated all the way, but not in the editor.

Is it possible to trigger a rebuild of the component?

exalate-issue-sync[bot] commented 2 years ago

Ref: INT-2723

jscasca commented 2 years ago

Hey @Cr3ature any chance you can share a reproduction of this case? If you have a github repo or something similar I can take a better look into it.

How are the values filled in for each editor? My guess is that is not triggering a setContent for the editor

Cr3ature commented 2 years ago

Hey @jscasca, I made a demo that reproduces my case. https://github.com/Cr3ature/MudBlazor-TinyMce

Hope this helps,

Best regards

Cr3ature commented 2 years ago

Hey @jscasca, did you by any chance have found a solution or workaround for this case?

jscasca commented 2 years ago

@Cr3ature sorry it took this long, December is a crazy period. The simple workaround should be using the @key directive in your TinyMceDemo component. This should ensure that the current component gets the correct reference. E.G:

<TextEditorComponent @key="sectionDemo"  @bind-Value="sectionDemo.Content"... />

Let me know if this helps

Cr3ature commented 2 years ago

@jscasca I know the feeling. The crazy period consists here. I tried adding the directive and it resolved my issue. Big thanks for looking into it.

I learned an important directive that will be used a lot in future codebases.