angular-ui / ui-tinymce

AngularUI wrapper for TinyMCE
MIT License
488 stars 371 forks source link

UnSafe Digest #248

Closed jmeisner3 closed 8 years ago

jmeisner3 commented 8 years ago

I am not sure I have adhered to the guidelines, but the general idea can be seen here. Excuse my spelling mistake. I was using the filemanager to trigger a modal, and the digest for the modal was overlapping with this digest, which throws an uncaught exception. This safe digest logic is being done on a digest earlier in the file, but not in this particular one.

https://github.com/jmeisner3/ui-tinymce/commit/cef677cbf0bda2e810ad5cc82db0d81b2573c1db

Careidas77 commented 8 years ago

I think what @jmeisner3 is referring to is the code around line 100, inside setupOptions:

ed.on('blur', function () { element[0].blur(); ngModel.$setTouched(); scope.$digest(); });

I ran into the same problem with the line scope.$digest(); causing a "digest already in progress" error. It should probably be wrapped inside a if (!scope.$$phase). That solved the problem for me, and I have yet to discover any unwanted side effects.

I'm using the $uibModal from ui.bootstrap to open a modal dialog, and every time I set focus inside the TinyMCE editor before opening the modal (from a button click, causing the blur event to be raised), the aforementioned error was thrown.