[FIX] web_editor: check if no selection in _handleSelectionInTable
Before this commit, if there were no selection in `_handleSelectionInTable` because the document was removed (in case the document was in a removed iframe), the method would crash. task-3052658 closes odoo/odoo#112908 X-original-commit: 8e23a4191730d5512c9de81c23f8e4e88e99ddb1 Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This commit is contained in:
@@ -2230,7 +2230,8 @@ export class OdooEditor extends EventTarget {
|
||||
*/
|
||||
_handleSelectionInTable(ev=undefined) {
|
||||
const selection = this.document.getSelection();
|
||||
const anchorNode = selection.anchorNode;
|
||||
// Selection could be gone if the document comes from an iframe that has been removed.
|
||||
const anchorNode = selection && selection.getRangeAt(0) && selection.anchorNode;
|
||||
if (anchorNode && (closestElement(anchorNode, '[data-oe-protected="true"]') || !ancestors(anchorNode).includes(this.editable))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user