Skip to content

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

@lwd8cmd

Description

@lwd8cmd

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions