summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoine Guenet <age@odoo.com>2019-04-16 12:05:28 +0000
committerAntoine Guenet <age@odoo.com>2019-04-25 10:03:14 +0000
commit27eb8ba61798e7bc65bb75becc3f89c839a61996 (patch)
tree1c8a2f95e4a51309cb0e0f012d41858e99145222
parentcb9263a8233894459e2238711d1633c1b7995de9 (diff)
[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 <pparidans@users.noreply.github.com>
-rw-r--r--addons/web_editor/static/src/js/wysiwyg/plugin/bullet.js4
-rw-r--r--addons/web_editor/static/tests/wysiwyg_keyboard_tests.js12
2 files changed, 16 insertions, 0 deletions
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: '<div><p>1</p></div><ul class="list-group list-group-flush"><li class="list-group-item"><p><br></p></li></ul>',
+ steps: [{
+ start: "p:eq(1)->0",
+ key: 'BACKSPACE',
+ }],
+ test: {
+ content: '<div><p>1</p></div><ul class="list-group list-group-flush"><li class="list-group-item"><p><br></p></li></ul>',
+ start: "p:eq(1)->0",
+ },
+ },
];
QUnit.test('Complex', function (assert) {