Skip to main content
1 of 2
Badan
  • 225
  • 1
  • 7

I finally figured out what the issue was. Apparently, when you remove the textarea element from the DOM, you also need to remove the wp editor that has been attached to it. (if you decide to re-add it to the DOM later) I found out that even though the textarea is successfully removed, its id is still stored in the tinyMCEPreInit object. Removing the wp editor with its corresponding textarea id fixed the issue for me:

function removeStep() {
    const steps = document.getElementsByClassName('step');
    const lastStep = steps[steps.length - 1];
    const lastTextArea = lastStep.getElementsByClassName('form-field')[1];
    lastStep.remove();
    if (typeof wp.editor != "undefined" && isShowWpEditor) {
        wp.editor.remove(lastTextArea.id);
    }
    counter--;
}
Badan
  • 225
  • 1
  • 7