From b1a0e00476ae665b30db0ed78752a4ace9e4f677 Mon Sep 17 00:00:00 2001 From: Jinjiu Liu <jili@odoo.com> Date: Thu, 14 Sep 2023 14:03:19 +0200 Subject: [PATCH] [FIX] web_editor: infinite loop in lists in table Reproduction: 1. Open Notes App 2. Type text in two lines 3. Add a table 4. Select the first two lines and press backspace 5. Page will become unresponsive. This is a backward port of: https://github.com/odoo/odoo/pull/126364 task-3504499 closes odoo/odoo#135486 Signed-off-by: David Monjoie (dmo) <dmo@odoo.com> --- .../static/lib/odoo-editor/src/OdooEditor.js | 3 ++- .../lib/odoo-editor/test/spec/editor.test.js | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js b/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js index bb00041704a1..e895cae603e4 100644 --- a/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js +++ b/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js @@ -1513,7 +1513,8 @@ export class OdooEditor extends EventTarget { doJoin && next && !(next.previousSibling && next.previousSibling === joinWith) && - this.editable.contains(next) + this.editable.contains(next) && + closestElement(joinWith, "TD") === closestElement(next, "TD") ) { const restore = preserveCursor(this.document); this.observerFlush(); diff --git a/addons/web_editor/static/lib/odoo-editor/test/spec/editor.test.js b/addons/web_editor/static/lib/odoo-editor/test/spec/editor.test.js index 53e632a2df92..f7b86faff6c9 100644 --- a/addons/web_editor/static/lib/odoo-editor/test/spec/editor.test.js +++ b/addons/web_editor/static/lib/odoo-editor/test/spec/editor.test.js @@ -924,6 +924,27 @@ X[] ), }); }); + it('should delete the list item', async () => { + await testEditor(BasicEditor, { + contentBefore: unformat( + `<table><tbody> + <tr> + <td><ul><li>[a</li><li>b</li><li>c]</li></ul></td> + <td><ul><li>A</li><li>B</li><li>C</li></ul></td> + </tr> + </tbody></table>`, + ), + stepFunction: deleteForward, + contentAfter: unformat( + `<table><tbody> + <tr> + <td><ul><li>[]<br></li></ul></td> + <td><ul><li>A</li><li>B</li><li>C</li></ul></td> + </tr> + </tbody></table>`, + ), + }); + }); it('should delete an image that is displayed as a block', async () => { await testEditor(BasicEditor, { contentBefore: unformat(`<div>a[b<img style="display: block;"/>c]d</div>`), -- GitLab