From a2350508b1c4570c93578f0ddf69e04751dc2e39 Mon Sep 17 00:00:00 2001 From: Jinjiu Liu Date: Fri, 17 Mar 2023 08:41:11 +0000 Subject: [PATCH] [FIX] web_editor: switch the checkbox of checklist to right for rtl Reproduction: 1. Create a /checklist, switch the direction by /swith 2. Type something and the list element is rtl, but the checkbox is on the left Fix: add margin to the right for checklist with the same value as what we have on the left, reset left and right position for the li element when we have rtl direction on the whole list. When we switch direction on a li element when set the direction on the list level, e.g. we get the cloest list element and set the direction for the whole list. opw-3215701 closes odoo/odoo#119423 X-original-commit: 01b42c7d76c814e13325f8880dc9de765b0f43c8 Signed-off-by: David Monjoie (dmo) Signed-off-by: Liu Jinjiu (jili) --- .../src/js/editor/odoo-editor/src/commands/commands.js | 2 +- addons/web_editor/static/src/scss/web_editor.common.scss | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/src/commands/commands.js b/addons/web_editor/static/src/js/editor/odoo-editor/src/commands/commands.js index 1f0fffc1814..e757deee2ee 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/src/commands/commands.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/src/commands/commands.js @@ -377,7 +377,7 @@ export const editorCommands = { const changedElements = []; const defaultDirection = editor.options.direction; const shouldApplyStyle = !isSelectionFormat(editor.editable, 'switchDirection'); - for (const block of new Set(selectedTextNodes.map(textNode => closestBlock(textNode)))) { + for (const block of new Set(selectedTextNodes.map(textNode => closestElement(textNode, 'ul,ol') || closestBlock(textNode)))) { if (!shouldApplyStyle) { block.removeAttribute('dir'); } else { diff --git a/addons/web_editor/static/src/scss/web_editor.common.scss b/addons/web_editor/static/src/scss/web_editor.common.scss index 3b523ccb920..b8c1ee47265 100644 --- a/addons/web_editor/static/src/scss/web_editor.common.scss +++ b/addons/web_editor/static/src/scss/web_editor.common.scss @@ -143,6 +143,7 @@ ul.o_checklist { list-style: none; position: relative; margin-left: $o-checklist-margin-left; + margin-right: $o-checklist-margin-left; &:not(.oe-nested)::before { content: ''; @@ -169,6 +170,11 @@ ul.o_checklist { } } } +ul.o_checklist[dir="rtl"] > li:not(.oe-nested)::before { + left: auto; + right: - $o-checklist-margin-left; + text-align: right; +} ol > li.o_indent, ul > li.o_indent { margin-left: 0; list-style: none;