Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timing issue with summernote 0.7.3 #113

Open
shadybones opened this issue Feb 4, 2016 · 1 comment
Open

timing issue with summernote 0.7.3 #113

shadybones opened this issue Feb 4, 2016 · 1 comment
Labels

Comments

@shadybones
Copy link
Contributor

I don't know why this doesn't affect 0.7.2, but it doesn't.
A-S code inside this.active:

     var updateNgModel = function() {
        var newValue = element.summernote('code');
        if (element.summernote('isEmpty')) { newValue = ''; }
        if (ngModel && ngModel.$viewValue !== newValue) {
          $timeout(function() {   //<<<<<<<<<Timeout 2
            ngModel.$setViewValue(newValue);
          }, 0);
        }
      };
     callbacks.onChange = function(contents) {
        $timeout(function() {   //<<<<<<<Timeout1
          if (element.summernote('isEmpty')) { contents = ''; }
          updateNgModel();
        }, 0);
        $scope.change({contents:contents, editable: $scope.editable});
      };

In this order (this is on init):

  1. Model set to Value1
  2. onChange is called with Value1, Timeout1 calls updateNgModel, which makes Timeout2.
  3. Model is set to Value2
  4. onChange is called again with Value2, which Triggers Timeout1, which calls updateNgModel, but does not create another Timeout 2.
  5. Timeout2 is now run, overwriting the up-to-date Value2, with the old Value1, on the Model.

Expected: Value2
Got: Value1

Fix: Would be for Timeout2 to check to see if 'updateNgModel' has been called again since it was created, and if so, do nothing.

@outsideris outsideris added the bug label Feb 13, 2016
@outsideris
Copy link
Owner

Could you check it in v0.8?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants