thijsw/angular-medium-editor

BUG: State changes are keeping the medium toolbars on page

Closed this issue · 4 comments

State changes are keeping the toolbars on page, this is causing to the bottom of the page being active, but empty.

[GIF] Bug below

bug

Fixed using this:

iElement.on('remove', function () {
    ctrl.editor.deactivate();
});

But there's some memory leak on overriding MediumEditors without deactivating existing ones.

me too... But the above didn't work for me. In the run of my main module I put:

    $rootScope.$on('$routeChangeStart', function(event, next){
      var mediumToolbar = angular.element('.medium-editor-toolbar');
      if (mediumToolbar.length) {
        mediumToolbar.remove();
      }
...

I fixed it by deactivating the editor on scope destroy

scope.$on('$destroy', function() {
    ctrl.editor.deactivate();
});

diefans fix works best. This should get into the code base.

There is still an issue, though. On submit, the toolbar remains active for me. Apparently the button click or tab+enter is not enough to trigger the toolbar removal.

Is there any way to get the medium editor from the angular element object to allow deactivate from outside code?