From 27eb8ba61798e7bc65bb75becc3f89c839a61996 Mon Sep 17 00:00:00 2001 From: Antoine Guenet Date: Tue, 16 Apr 2019 12:05:28 +0000 Subject: [PATCH] [FIX] web_editor, website: never indent/outdent list groups The "comparisons" website snippet uses a list group with the class set on a UL. In consequence, the web editor considers it as a regular list and may try to outdent it, which is not the expected behavior with a list group. This fix ensures that ULs with the `list-group` class cannot be in/outdented. closes odoo/odoo#32709 Signed-off-by: Pierre Paridans --- .../static/src/js/wysiwyg/plugin/bullet.js | 4 ++++ .../static/tests/wysiwyg_keyboard_tests.js | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/addons/web_editor/static/src/js/wysiwyg/plugin/bullet.js b/addons/web_editor/static/src/js/wysiwyg/plugin/bullet.js index 59dbdd2c477..dc2a444384b 100644 --- a/addons/web_editor/static/src/js/wysiwyg/plugin/bullet.js +++ b/addons/web_editor/static/src/js/wysiwyg/plugin/bullet.js @@ -313,6 +313,10 @@ var BulletPlugin = AbstractPlugin.extend({ if (!range) { return; } + // list groups shouldn't be outdented like regular lists + if ($(dom.ancestor(range.sc, dom.isList)).hasClass('list-group')) { + return; + } var self = this; var nodes = []; diff --git a/addons/web_editor/static/tests/wysiwyg_keyboard_tests.js b/addons/web_editor/static/tests/wysiwyg_keyboard_tests.js index 86a7c716cc6..e59f8d14539 100644 --- a/addons/web_editor/static/tests/wysiwyg_keyboard_tests.js +++ b/addons/web_editor/static/tests/wysiwyg_keyboard_tests.js @@ -2227,6 +2227,18 @@ var keyboardTestsComplex = [{ start: "p:contents()[0]->1", }, }, + { + name: "in ul.list-group (div > p > text before): BACKSPACE at start", + content: '

1

', + steps: [{ + start: "p:eq(1)->0", + key: 'BACKSPACE', + }], + test: { + content: '

1

', + start: "p:eq(1)->0", + }, + }, ]; QUnit.test('Complex', function (assert) {