diff --git a/Changelog.md b/Changelog.md index 1cc8b4936913f7b3b333ea6c99b99dbb2f8d9e40..162d2fd371ee8eedd0270273829fbdda1eda2e90 100644 --- a/Changelog.md +++ b/Changelog.md @@ -30,6 +30,7 @@ If so, please delete it since it will prevent the federation from working proper * Fix height too high on mobile SPV [#7480](https://github.com/diaspora/diaspora/pull/7480) * Improve stream when ignoring a person who posts a lot of tagged posts [#7503](https://github.com/diaspora/diaspora/pull/7503) * Fix order of comments across pods [#7436](https://github.com/diaspora/diaspora/pull/7436) +* Prevent publisher from closing in preview mode [#7518](https://github.com/diaspora/diaspora/pull/7518) ## Features * Add support for mentions in comments to the backend [#6818](https://github.com/diaspora/diaspora/pull/6818) diff --git a/app/assets/javascripts/app/views/publisher_view.js b/app/assets/javascripts/app/views/publisher_view.js index 160a77a95d043373ae8af024add8cb6538014639..211153198e402be2ab40c16f38412d4681b71ecb 100644 --- a/app/assets/javascripts/app/views/publisher_view.js +++ b/app/assets/javascripts/app/views/publisher_view.js @@ -407,8 +407,8 @@ app.views.Publisher = Backbone.View.extend({ }, tryClose : function(){ - // if it is not submittable, close it. - if( !this._submittable() ){ + // if it is not submittable and not in preview mode, close it. + if (!this._submittable() && !this.markdownEditor.isPreviewMode()) { this.close(); } }, diff --git a/spec/javascripts/app/views/publisher_view_spec.js b/spec/javascripts/app/views/publisher_view_spec.js index 8d02015ea5dfa5592d2721bf4edbc327b235c2a3..e286c3cf6dd5f981ef4d03625d6e5458a761e2e9 100644 --- a/spec/javascripts/app/views/publisher_view_spec.js +++ b/spec/javascripts/app/views/publisher_view_spec.js @@ -252,6 +252,31 @@ describe("app.views.Publisher", function() { }); }); + describe("tryClose", function() { + it("doesn't close the publisher if it is submittable", function() { + spyOn(this.view, "_submittable").and.returnValue(true); + spyOn(this.view, "close"); + this.view.tryClose(); + expect(this.view.close).not.toHaveBeenCalled(); + }); + + it("doesn't close the publisher if it is in preview mode", function() { + spyOn(this.view, "_submittable").and.returnValue(false); + spyOn(this.view.markdownEditor, "isPreviewMode").and.returnValue(true); + spyOn(this.view, "close"); + this.view.tryClose(); + expect(this.view.close).not.toHaveBeenCalled(); + }); + + it("closes the publisher if it is neither submittable nor in preview mode", function() { + spyOn(this.view, "_submittable").and.returnValue(false); + spyOn(this.view.markdownEditor, "isPreviewMode").and.returnValue(false); + spyOn(this.view, "close"); + this.view.tryClose(); + expect(this.view.close).toHaveBeenCalled(); + }); + }); + describe("_beforeUnload", function(){ it("calls _submittable", function(){ spyOn(this.view, "_submittable");