When hitting save or preview on a form which uses Wysiwyg with CKEditor the editor disappears leaving only the HTML textbox and the html for the content entered for the few seconds until the next page loads. This is rather ugly and it would be better if CKEditor stayed in place the entire time. Is there anyway to accomplish this?

CommentFileSizeAuthor
#23 wysiwyg-dont-detach-1033718.patch350 bytesadr_p

Comments

sun’s picture

Version: 6.x-2.1 » 7.x-2.x-dev

This can only be fixed for D7. Not sure whether this is a duplicate, no time to search right now.

Dean Reilly’s picture

Understood. Does anyone know if this is specific to CKEditor or whether all editors are affected? (Don't have the time to check right now but if no one responds by tomorrow I'll run through them all and take a look.)

sun’s picture

This affects all editors.

twod’s picture

The reason is simply that Wysiwyg currently runs the same code when syncing the editor's contents back to the original textarea on a form submit as it switching between editors (a call to the editor's detach() method). We should perhaps add a save() or sync() method to the implementation layer?

bryancasler’s picture

subscribe

twod’s picture

Title: CKEditor disappears while form is submitting » Editors disappear while form is submitting

This applies to all editors.

bryancasler’s picture

Any update on this?

twod’s picture

Nope, #4 still applies.
Note also that some editors may detach like this on purpose, to clean up event handlers and cross references between DOM objects and script objects so they won't cause memory leaks in certain browsers.

bryancasler’s picture

Thanks for the down and dirty TwoD

tirdadc’s picture

Are there any work-arounds for this in the meantime?

I am applying this patch and I'm wondering if this issue is related to its use.

twod’s picture

No, there are no workarounds. We need to differentiate between what happens when switching between editors and when submitting the form for this visual annoyance to go away.

shady_gun’s picture

Version: 7.x-2.1 » 7.x-2.x-dev
Category: bug » support
Priority: Critical » Minor

Any updates on this?? The editor disappears when you hit save button and when you try to embed media youtube http://drupal.org/project/media_youtube the raw source code is embedded instead of Video .

Edits

I tried with both tinyMCE and CKEeditor

shady_gun’s picture

Version: 7.x-2.x-dev » 7.x-2.1
Category: support » bug
Priority: Minor » Critical
twod’s picture

Category: support » feature

Editors disappearing is not a bug, the editors are detached/destroyed to sync the generated source code back to the original textarea - or nothing would be saved - and to prevent memory leaks from building up due to circular references between JavaScripts and DOM objects surviving page reloads.
This might not be necessary for all editors but it's the safest way to avoid potential browser crashes. Several of the more popular editors have built in cleanup routines that detect form submissions and destroy themselves for the very same reason.

It _might_ be possible to limit the visual effects of this, and allow editors that don't require full detachment to stay visible, by adding a new method to our editor API that'll just do the syncing part. It's something I've been thinking about adding to #614146: Drupal.wysiwyg.editor.instance needs additional methods but I haven't gotten that far yet. Hence, I'm turning this into a feature request for that just in case it doesn't get into the other issue.

I can't say exactly what happens with media_youtube.module since I haven't tried it, but if the video can actually be played when viewing the node, all is well.

twod’s picture

Priority: Minor » Normal

Whoops.

shady_gun’s picture

Thanks for the explanation and update Henrik ..

mitylite’s picture

Not satisfied with that explanation. I've never seen this on any website systems besides drupal. No forum i've ever used had this problem, so its clearly not an impossible task nor a necessary feature.

Looks absolutely unprofessional, which is something I've notice drupal has big issues with prior to D7... It's unfortunate this module has rationalized a reason to maintain that tradition in D7. Get rid of it. No mercy for it. Kill it.

AgaPe’s picture

+

SlayJay’s picture

I agree 100% with #17... this makes drupal look sloppy.

nzcodarnoc’s picture

I guess it comes down to how you define a bug.

From a technical point of view it's clearly not a bug.

However, in my opinion it's a usability problem.

This opinion is based on the phone call I had with a client this morning, who though that the save button had to be clicked twice.

She formed this impression because, in her mind, when the WYSIWYG editors disappeared, she was on a new page.

That is to say, that her interpretation of a "new page", is when there is a significant change in the appearance of the page.

So she clicked save again, and was informed her changes couldn't be saved. Only to discover that her changes had been saved.

Granted, we are working on a slow staging server, so it's likely to be less of a problem when live.

For all of these reasons I think this is a usability issue serious enough to be called a bug.

My current thinking is that I will bind something to the save button that puts a transparent matte over the whole page as it saves.

bryancasler’s picture

nzcodarnoc, I'd be interested in the transparent matte solution for the interim. Please keep us informed. You may also want to look at this module, I haven't yet tested the D7 dev release. http://drupal.org/project/hide_submit

nzcodarnoc’s picture

Note: the site I'm working on is Drupal 6

I've implemented this leveraging the matte in Lightbox2, so you will need to have Lightbox2 installed for this to work.

First of all I created a custom module and put the following in hook_form

function modulename_form_alter(&$form, &$form_values, $form_id)
{
  drupal_add_js(drupal_get_path('module', 'modulename').'/modal-saving.js');
  // rest of hook_form_alter (if required)
}

Then in the modulename folder I add the file modal-saving.js

Drupal.behaviors.modulename_modal_saving = function(context) {
  $('#edit-submit, #edit-save').click(function() {
    $('body').append('<div id="lightboxAutoModal" style="display: none;" rel="lightmodal[|width:400px; height:50px;]" ><p>Saving...</p></div>');
    Lightbox.initList(context);
    $('#lightboxAutoModal', context).triggerHandler('click');
  });
};
adr_p’s picture

StatusFileSize
new350 bytes

I've prepared a simple patch which causes WYSIWYG to fill original textarea instead of detaching the editor when the form is submitted. I've tested it only with CKEditor. Also, there can be consequences of using this solution, TwoD wrote about those earlier. Prior to applying the patch you must apply the one attached here: http://drupal.org/node/614146#comment-5667126.

Please don't hesitate to post comments.

twod’s picture

@adr_p, I would not recommend that approach. It's simple, but will leave the editor instance in memory. That may lead to errors saying the editor instance already exists if the form doesn't actually complete the submission (AJAX).
We've been working on fixing the AJAX problem in #1388224: editors detach on AJAX form submission, and that could be generalized to leave only the visual elements of the editor intact for normal submits as well. That patch does not need the patch in #614146-41: Drupal.wysiwyg.editor.instance needs additional methods, but works together with it if you need it for some other reason.

I'm going to commit that patch soon, but ran into a few issues while trying to backport it to D6.

Ivat’s picture

I run into the same problem using Wysiwyg 7.x-2.1 width CKEditor 3.6.3.7474
Is there any temporary fix to this issue?

Thanks in advance.

twod’s picture

Try Wysiwyg 7.x-2.x-dev. I've committed a patch from #1388224: editors detach on AJAX form submission to the D7 branch. Once that patch was in, a single line change in it should have fixed this issue as well so I put it in there.
It does not seem possible to directly port that patch back to the D6/5 branches since it depends on some changes made to D7 core, but perhaps we can at least port the portion of that patch which will fix the issue discussed here for D6/5 as well.

I'll take a look at that if I get some free time during the weekend.

adr_p’s picture

@TwoD
I see your point in #24, but there are many other ways (than hitting submit) user can leave a page containing editor, e.g. by following a link. Wouldn't it cause the problem you've described?

Ivat’s picture

Thanks TwoD ! This version works fine : 7.x-2.x-dev (2012-Jul-08).

twod’s picture

Issue summary: View changes
Status: Active » Closed (duplicate)
Related issues: +#1388224: editors detach on AJAX form submission

I'm closing this as a duplicate of #1388224: editors detach on AJAX form submission, which was commited long ago.
Editors which support updating the original textarea without detaching completely (most of them) now do so, and only perform the amount of cleanup needed to avoid [known] memory leaks.

Navigating away from a page with a link is usually handled by an editor using the document's onunload event, and it will perform the necessary cleanup on its own.