Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

fix($dirty): check if editor is dirty before updating view #239

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/tinymce.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions src/tinymce.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ angular.module('ui.tinymce', [])
$timeout.cancel(debouncedUpdateTimer);
debouncedUpdateTimer = $timeout(function() {
return (function(ed) {
ed.save();
updateView(ed);
if (!ed.isNotDirty) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want ed.isDirty() instead.

ed.save();
updateView(ed);
}
})(ed);
}, debouncedUpdateDelay);
};
Expand Down
11 changes: 11 additions & 0 deletions test/tinymce.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,17 @@ describe('uiTinymce', function () {
done();
}, 100);
});
it('shouldn\'t make the form dirty', function(done) {
compile();
setTimeout(function() {
scope.foo = text;
scope.$apply();

expect(directiveElement.controller('form').$dirty).toBe(false);

done();
});
});
// TODO: Fix test
xit('should handle undefined gracefully', function(done) {
compile();
Expand Down