[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>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user