[FIX] web_editor: do not affect selection outside of the editable
Unfortunately, the selectionchange event is triggered on document, so we need to be careful not to affect the selection if it is not in the editable. Part-of: odoo/odoo#99896
This commit is contained in:
@@ -3116,6 +3116,13 @@ export class OdooEditor extends EventTarget {
|
||||
*/
|
||||
_onSelectionChange() {
|
||||
const selection = this.document.getSelection();
|
||||
if (
|
||||
!this.editable.contains(selection.anchorNode) &&
|
||||
!this.editable.contains(selection.focusNode)
|
||||
) {
|
||||
// Do not affect selection outside of the editable.
|
||||
return;
|
||||
}
|
||||
// When CTRL+A in the editor, sometimes the browser use the editable
|
||||
// element as an anchor & focus node. This is an issue for the commands
|
||||
// and the toolbar so we need to fix the selection to be based on the
|
||||
|
||||
Reference in New Issue
Block a user