From a27837a0004dcf5fd412bc36b2e7a28a39f8291d Mon Sep 17 00:00:00 2001 From: Antoine Guenet Date: Mon, 28 Jan 2019 10:35:06 +0000 Subject: [PATCH] [FIX] web_editor: properly disable the toolbar on snippet removal Update editor toolbar on each change to properly disable it when needed closes odoo/odoo#30594 --- .../static/src/js/wysiwyg_snippets/wysiwyg_snippets.js | 1 + addons/web_editor/static/tests/wysiwyg_snippets_tests.js | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/web_editor/static/src/js/wysiwyg_snippets/wysiwyg_snippets.js b/addons/web_editor/static/src/js/wysiwyg_snippets/wysiwyg_snippets.js index d1dc29ca7b1..0f411343486 100644 --- a/addons/web_editor/static/src/js/wysiwyg_snippets/wysiwyg_snippets.js +++ b/addons/web_editor/static/src/js/wysiwyg_snippets/wysiwyg_snippets.js @@ -150,6 +150,7 @@ Wysiwyg.include({ if (this.snippets) { this.snippets.updateCurrentSnippetEditorOverlay(); } + this._summernote.invoke('toolbar.update', true); this._super.apply(this, arguments); }, /** diff --git a/addons/web_editor/static/tests/wysiwyg_snippets_tests.js b/addons/web_editor/static/tests/wysiwyg_snippets_tests.js index 2441897b36d..5f249feb30a 100644 --- a/addons/web_editor/static/tests/wysiwyg_snippets_tests.js +++ b/addons/web_editor/static/tests/wysiwyg_snippets_tests.js @@ -175,7 +175,7 @@ QUnit.test('clean the dom before save', function (assert) { QUnit.test('remove snippet', function (assert) { var done = assert.async(); - assert.expect(1); + assert.expect(2); return weTestUtils.createWysiwyg({ wysiwygOptions: { @@ -186,7 +186,9 @@ QUnit.test('remove snippet', function (assert) { var $editable = wysiwyg.getEditable(); testUtils.mock.intercept(wysiwyg, "snippet_focused", function () { + $('.note-btn-bold').removeClass('o_disabled'); $('#oe_manipulators .oe_overlay_options .oe_snippet_remove').click(); + assert.ok($('.note-btn-bold').hasClass('o_disabled')); wysiwyg.save().then(function (isDirty, html) { assert.strictEqual(html.replace(/\s+/g, ' '), '', "should remove the snippet");