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

Text becomes blank if DOM elements are added or removed around tinymce instance #230

Open
lwd8cmd opened this issue Mar 16, 2021 · 11 comments
Labels
bug Something isn't working GitHub status: escalated

Comments

@lwd8cmd
Copy link

lwd8cmd commented Mar 16, 2021

What is the current behavior?
Text becomes blank and is not editable if parent siblings in DOM tree are removed or added.

**Please provide the steps to reproduce and if possible a minimal demo of the problem

<script>
import TinyMce from '@tinymce/tinymce-vue';

export default {
  components: {
    TinyMce,
  },
  data: function() {
    return {
      text: 'text',
      instructionsVisible: false,
    };
  },
};
</script>

<template lang="html">
  <div>
    <label><input type="checkbox" v-model="instructionsVisible" /> Click me</label>
    <p v-if="instructionsVisible">Lorem ipsum dolor sit amet</p>
    <div><tiny-mce v-model="text"/></div>
    <p v-if="instructionsVisible">Lorem ipsum dolor sit amet</p>
  </div>
</template>

Working demo: https://codepen.io/lwd8cmd/pen/rNWbXYx

Bug is probably caused by Vue moving div block containing tiny-mce editor around in DOM tree if p-tags are added. Vue doesn't keep content in another document (editable text held in iframe) if div block is moved to another location in DOM.

Call stack:

  • Vue._update
  • patch - update DOM structure
  • patchVnode - patch existing root node (root div)
  • updateChildren - update root div children (remove p tags, move div tag containing tiny-mce component)
  • insertBefore - move div containing tiny-mce component to another location

What is the expected behavior?
Text editor content shouldn't change, text should stay editable.

Which versions of TinyMCE, and which browser / OS are affected by this issue? Did this work in previous versions of TinyMCE or tinymce-vue?
Bug occurred in Tinymce-vue 3.0 and 3.2.8. Tested using Chrome 88, but bug should be browser-agnostic.

@jscasca jscasca added the bug Something isn't working label Mar 23, 2021
@dimer47
Copy link

dimer47 commented Apr 8, 2021

Hi @lwd8cmd 👋🏻

I have found a bypass solution to this problem on other GitHub issue and I wanted to share with you : #48 (comment)
I copied your codepen to make an update with this solution : https://codepen.io/dimer47/pen/xxgPKwL

I hope I helped you and that TinyMCE fix this problem quickly,
Dimer47

@exalate-issue-sync
Copy link

Ref: INT-2498

@nerdymind-dev
Copy link

Just wanted to mention the same issue happens when using the sortable js extension: https://github.com/SortableJS/vue.draggable.next

After dragging/dropping the DOM is re-ordered and the dragged elements text becomes invisible (though it is still there)

The same workaround works by using the sortable @end callback to quickly hide/show the TinyMCE container to force a re-render.

Having a way to call refresh/redraw on the <editor> component would be helpful to remove the flash that occurs when hiding/showing quickly.

@fecorreiabr
Copy link

I had the same issue when using the editor inside a Vuetify v-dialog and was able to solve it by using the bypass mentioned by @dimer47: #48 (comment)

@luismabenitez
Copy link

Same problem as @nerdymind-dev using vue-draggable. Any update on this?

@angelicochris
Copy link

angelicochris commented Mar 23, 2022

Just ran into this myself. The above codepens do not seem to work for me and the solution proposed here doesn't work either.

@keygun-development
Copy link

Same issue here. Solution of @dimer47 works, but is not ideal

@scx567888
Copy link

Same issue here. This should be tinymce bug not tinymce-vue bug.

@derwaldgeist
Copy link

The same workaround works by using the sortable @end callback to quickly hide/show the TinyMCE container to force a re-render.

Having a way to call refresh/redraw on the <editor> component would be helpful to remove the flash that occurs when hiding/showing quickly.

I want to second that, as I ran into the same problem with sortable (using vue-draggable-plus). In my case, I am using multiple instances, one in each draggable item. So the approach with disabling / re-enabling the DOM element on next tick gets even more cumbersome.

I tried different approaches, including those mentioned here:

https://stackoverflow.com/questions/4651676/how-do-i-remove-tinymce-and-then-re-add-it

but this did not work.

It would be really nice if TinyMCE would offer to re-initialize an instance if the DOM element has been moved to a new location.

@tiny-stale-bot
Copy link

This issue is stale because it has been open 30 days with no activity. Please comment if you wish to keep this issue open or it will be closed in 7 days.

@tiny-stale-bot tiny-stale-bot added the status:stale An issue that has been left with no response for an extended period of time. label Jul 9, 2024
@derwaldgeist
Copy link

@tiny-stale-bot This issue is still relevant. We also see issues when moving TinyMCE around in the DOM, like as part of a drag & drop operation.

@danoaky-tiny danoaky-tiny added status: escalated and removed status:stale An issue that has been left with no response for an extended period of time. labels Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working GitHub status: escalated
Projects
None yet
Development

No branches or pull requests