[FIX] web_editor: link is added inside a br element in chrome
Reproduction: 1. Create a link right after some text 2. Remove the whole line by backspace character by character(this should give the p element a history steps id) 3. Try to create a link again 4. The new link is invisible and actually created in br when inspecting the page Reason: this is an edge case on Chrome that the document.getSelection() returns a selection which has br element as the anchorNode. It may happen when the parent element of the br has history steps and only has this br element. However, the same steps done on Firefox return the correct selection on the parent element. Fix: we make a special case when the selection is a caret type and the anchorNode is a br element, we re-select the parent element and collapse the selection to the start. This is trying to mimic the normal case of adding a link to an empty p element, e.g selection anchorNode is p, offset is 0. task-3181486 closes odoo/odoo#136777 X-original-commit: 540dcc71 Signed-off-by:David Monjoie (dmo) <dmo@odoo.com>
Loading
Please register or sign in to comment