From 17aff7b59b7b5e997da14a00e0df1d2ed7c16164 Mon Sep 17 00:00:00 2001 From: Antoine Guenet Date: Mon, 15 Apr 2019 11:40:05 +0000 Subject: [PATCH] [FIX] web_editor: uncheck new checklist item on split On ENTER in a checklist item, a new checklist item is created. The new one should never be checked. This ensures that ENTER in a checked checklist item never creates a checked checklist item but instead cleans the class. closes odoo/odoo#32684 Signed-off-by: Pierre Paridans --- .../static/src/js/wysiwyg/plugin/keyboard.js | 1 + .../static/tests/wysiwyg_keyboard_tests.js | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/addons/web_editor/static/src/js/wysiwyg/plugin/keyboard.js b/addons/web_editor/static/src/js/wysiwyg/plugin/keyboard.js index 3ab6a5f0317..94ec9306f7d 100644 --- a/addons/web_editor/static/src/js/wysiwyg/plugin/keyboard.js +++ b/addons/web_editor/static/src/js/wysiwyg/plugin/keyboard.js @@ -296,6 +296,7 @@ var KeyboardPlugin = AbstractPlugin.extend({ var next = this.context.invoke('HelperPlugin.splitTree', ancestor, point, { isSkipPaddingBlankHTML: !this.context.invoke('HelperPlugin.isNodeBlockType', point.node.parentNode) && !!point.node.parentNode.nextSibling }); + $(next).removeClass('o_checked'); while (next.firstChild) { next = next.firstChild; } diff --git a/addons/web_editor/static/tests/wysiwyg_keyboard_tests.js b/addons/web_editor/static/tests/wysiwyg_keyboard_tests.js index 56ceb27a025..28a8106234c 100644 --- a/addons/web_editor/static/tests/wysiwyg_keyboard_tests.js +++ b/addons/web_editor/static/tests/wysiwyg_keyboard_tests.js @@ -1179,6 +1179,30 @@ var keyboardTestsEnter = [{ start: "br->0", }, }, + { + name: "in ul.o_checklist > li.o_checked > p: ENTER at end", + content: '', + steps: [{ + start: "p:contents()[0]->4", + key: 'ENTER', + }], + test: { + content: '', + start: "br->0", + }, + }, + { + name: "in ul.o_checklist > li.o_checked > p > b: ENTER within text", + content: '', + steps: [{ + start: "b:contents()[0]->2", + key: 'ENTER', + }], + test: { + content: '', + start: "b:eq(1):contents()[0]->0", + }, + }, // end list UL / OL