summaryrefslogtreecommitdiff
path: root/addons/web_editor/static
diff options
context:
space:
mode:
authorAntoine Guenet <age@odoo.com>2019-07-11 13:20:28 +0000
committerAntoine Guenet <age@odoo.com>2019-07-11 14:41:12 +0000
commite7828c362718b40ed74920a1ce3619766fa84ff2 (patch)
treec4f28eef1283ac74126f2c8682208a78ae678567 /addons/web_editor/static
parent5b41b5c563c75e18f4cf8d2f7dd66d5e273e4341 (diff)
[FIX] web_editor: properly insert character in empty nested list
Fix a bug that can be reproduced like so: - Insert list - Type char - ENTER - TAB - Type char The character gets inserted _after_ the `br` instead of replacing it. closes odoo/odoo#34805 Signed-off-by: Pierre Paridans <pparidans@users.noreply.github.com>
Diffstat (limited to 'addons/web_editor/static')
-rw-r--r--addons/web_editor/static/src/js/wysiwyg/plugin/helper.js3
-rw-r--r--addons/web_editor/static/tests/wysiwyg_keyboard_tests.js31
2 files changed, 34 insertions, 0 deletions
diff --git a/addons/web_editor/static/src/js/wysiwyg/plugin/helper.js b/addons/web_editor/static/src/js/wysiwyg/plugin/helper.js
index a025d6a0082..1738e6e7b48 100644
--- a/addons/web_editor/static/src/js/wysiwyg/plugin/helper.js
+++ b/addons/web_editor/static/src/js/wysiwyg/plugin/helper.js
@@ -1885,6 +1885,9 @@ var HelperPlugin = AbstractPlugin.extend({
// Create empty text node to have a range into the node
if (range.sc.tagName && !dom.isVoid(range.sc) && !range.sc.childNodes[range.so]) {
$(range.sc).append(invisible);
+ if (invisible.previousSibling && invisible.previousSibling.tagName === "BR") {
+ invisible.previousSibling.remove();
+ }
range = this.context.invoke('editor.setRange', invisible, 0);
}
diff --git a/addons/web_editor/static/tests/wysiwyg_keyboard_tests.js b/addons/web_editor/static/tests/wysiwyg_keyboard_tests.js
index e59f8d14539..861b574f9c6 100644
--- a/addons/web_editor/static/tests/wysiwyg_keyboard_tests.js
+++ b/addons/web_editor/static/tests/wysiwyg_keyboard_tests.js
@@ -811,6 +811,18 @@ var keyboardTestsChar = [{
start: "b:contents(0)->1",
},
},
+ {
+ name: "'a' in empty li",
+ content: '<ul><li><p><br></p></li></ul>',
+ steps: [{
+ start: "p->1",
+ key: 'a',
+ }],
+ test: {
+ content: '<ul><li><p>a</p></li></ul>',
+ start: "p:contents(0)->1",
+ },
+ },
];
QUnit.test('Char', function (assert) {
@@ -2239,6 +2251,25 @@ var keyboardTestsComplex = [{
start: "p:eq(1)->0",
},
},
+ // List indent
+ {
+ name: "ENTER -> TAB -> a' at end of li > p (split -> indent -> write)",
+ content: '<ul><li><p>a</p></li></ul>',
+ steps: [{
+ start: "p:contents()[0]->1",
+ key: 'ENTER',
+ },
+ {
+ key: 'TAB',
+ },
+ {
+ key: 'a',
+ }],
+ test: {
+ content: '<ul><li><p>a</p></li><li class="o_indent"><ul><li><p>a</p></li></ul></li></ul>',
+ start: "p:eq(1):contents()[0]->1",
+ },
+ },
];
QUnit.test('Complex', function (assert) {