Description:
This issue is not consistent, it appears sporadically after several open/closes of modal window.
I couldn't figure out the exact reason, error is thrown from CKEditor, see the debug backtrace screenshot attached.
As you can see on screenshot it happens on Drupal.wysiwygAttach() call on markup that doesn't have any WYSIWYG attached yet.
As the result wysiwyg is not attached to fields and Drupal.attachBehavior() execution is interrupted which prevents other JS to be attached to the form.

Steps to reproduce:
1. Create custom text field using CKEditor for file entity form
2. Open file entity form using ctools modal window
3. Open and close modal form several times until you get error in browser console: "Cannot read property 'clearCustomData' of null"

CKEditor version "4.4.1"
Wysiwyg version "7.x-2.2+54-dev"

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ssemashka’s picture

Assigned: ssemashka » Unassigned
Issue summary: View changes
Status: Needs work » Needs review
FileSize
562 bytes

Submitting a patch to wrap CKEditor method call by try/catch block.
During debugging I realized CKEditor throws a lot of uncaught exceptions, so wrapping external library calls by try/catch seems appropriate here.
It doesn't solve the entire issue, but at least doesn't break Drupal.attachBehaviors() execution and allows other behaviors to be attached.
I have a guess there should be additional check before calling detachFromField() inside Drupal.wysiwygAttach() to completely solve the issue, but don't have enough understanding of library yet.
I appreciate If anyone would suggest any better solution.

ssemashka’s picture

deleted message

TwoD’s picture

Status: Needs review » Postponed (maintainer needs more info)
Issue tags: -ckeditor, -ctools, -Modal Forms
Related issues: +#2243413: Error when adding field items - Add another item

If the call fails, it's because the instance is no longer there. If the instance is no longer there, Wysiwyg lost track of when it was destroyed.
Once that happens, it can't trust any internal state anymore.
Thanks for the patch, but I'd rather fix the state sync issues than hide the consequences.

Could you try the patch in #2243413: Error when adding field items - Add another item and see if that helps? I think building on that would make form/editor state tracking more reliable.

(Btw, browser support for console.log is so so...)

ssemashka’s picture

TwoD, thanks for reference, I tried the patch and described issue is gone. I'll leave the possibility to close this issue for you.
Thanks again.