Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iframe is broken when the component is removed from DOM by React #403

Open
moroine opened this issue Nov 14, 2022 · 5 comments
Open

Iframe is broken when the component is removed from DOM by React #403

moroine opened this issue Nov 14, 2022 · 5 comments
Labels
bug A replicated bug. GitHub Issues that have been added to our internal issue tracker. status: escalated

Comments

@moroine
Copy link

moroine commented Nov 14, 2022

What is the current behavior?
React uses add/remove to manipulate DOM. But when iframe is removed from DOM it looses its context (see whatwg/dom#891).

TinyMce doesn't detect iframe reload

Please provide the steps to reproduce and if possible a minimal demo of the problem via codesandbox.io or similar.
https://codesandbox.io/embed/eloquent-heisenberg-du24mx?fontsize=14&hidenavigation=1&theme=dark

What is the expected behavior?

TinyMce detect iframe reload, and reinitialize (similarly to unmount/remount). Not sure if the fix should be part of main tinymce 🤔

But here is a workaround https://codesandbox.io/s/cool-meadow-zrr0t1?file=/src/index.js

Which versions of TinyMCE, and which browser / OS are affected by this issue? Did this work in previous versions of TinyMCE or tinymce-react?

  • TinyMCE: 4.2.0
@exalate-issue-sync exalate-issue-sync bot added the GitHub Issues that have been added to our internal issue tracker. label Nov 14, 2022
@exalate-issue-sync
Copy link

Ref: INT-3049

@msageryd
Copy link

msageryd commented Nov 15, 2022

We have the same issue.
Instead of one editor and one button, as in your example, we render multiple editors from a list. When we reorder the editors the reordered editor breaks, i.e. it show no content.

We have tested our setup with multiple editors (CKEditor, Froala, Draft.js). None of the other editors suffer from this problem.

Related issues:
#295
#242

@tiny-james said in one of the above therads that this might be fixed in Tiny 6, but this doesn't seem to have happened. James, do you have any updates on this?

I tried to implement one of the suggested workarounds, but I failed. It would be awesome if anyone could build upon the codesandbox from @moroine and show how and when to call editor.remove() and editor.add() to recreate an editor.

Edit: Sorry, I missed that @moroine also presented a workaround. I'll try that and see where we go from this. This issue is quite concerning, so we might end up not using Tiny.

@moroine
Copy link
Author

moroine commented Nov 15, 2022

@msageryd yeah, we also render a list, but here I tried to reproduce a minimal case.

@yacodes
Copy link

yacodes commented Dec 12, 2022

@moroine @msageryd I've reproduced this issue and can confirm that it's a problem. We will look into it and will let you know when it will be fixed.

Thanks for the suggested workaround. Consider using it, until we'll fix the problem.

@yacodes yacodes added the bug A replicated bug. label Dec 12, 2022
@tiny-james
Copy link
Contributor

As msageryd mentioned it is a long-running known issue. It's primarily to do with Iframes losing state when they are removed from the DOM. TinyMCE needs to be changed to detect when it has been readded to the DOM and recreate the content.

There was a proof of concept implementation created internally but it never made it into TinyMCE 6 and has since stalled - I will try to get people working on it again. Sorry for getting people's hopes up.

@danoaky-tiny danoaky-tiny removed the bug A replicated bug. label Nov 24, 2023
@danoaky-tiny danoaky-tiny pinned this issue Nov 24, 2023
@danoaky-tiny danoaky-tiny added the bug A replicated bug. label Dec 4, 2023
@tinymce tinymce deleted a comment from tiny-stale-bot Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A replicated bug. GitHub Issues that have been added to our internal issue tracker. status: escalated
Projects
None yet
Development

No branches or pull requests

5 participants