diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js b/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js
index 0b31d685568..5b69160db6a 100644
--- a/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js
+++ b/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js
@@ -711,6 +711,19 @@ export class OdooEditor extends EventTarget {
return false;
}
+ // If the common ancestor is in a nested list, make sure to sanitize
+ // that list's parent
instead, so there is enough context to
+ // potentially merge sibling nested lists
+ // (eg,
+ //
+ //
+ //
: these two lists should be merged together so the common
+ // ancestor should be the element).
+ const nestedListAncestor = closestElement(commonAncestor, '.oe-nested');
+ if (nestedListAncestor && nestedListAncestor.parentElement) {
+ commonAncestor = nestedListAncestor.parentElement;
+ }
+
// sanitize and mark current position as sanitized
sanitize(commonAncestor);
this._pluginCall('sanitizeElement', [commonAncestor]);
diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/list.test.js b/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/list.test.js
index d0ca544fbdc..fbd516d9e51 100644
--- a/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/list.test.js
+++ b/addons/web_editor/static/src/js/editor/odoo-editor/test/spec/list.test.js
@@ -315,6 +315,17 @@ describe('List', () => {
`),
stepFunction: toggleCheckList,
+ contentAfterEdit: unformat(`
+ `),
contentAfter: unformat(`