[IMP] web_drop_target: Avoid errors for undefined elements

This changes are done to avoid errors in dms_field. This error is
found using this other PR: https://github.com/OCA/dms/pull/310

The steps to reproduce the error are:
1. Create a directory or a file without using drag and drop
2. Drag and drop a file into a folder and you will see the error
This commit is contained in:
Carlos Roca
2024-03-08 14:20:23 +01:00
parent dac33645f2
commit 81fcf6cce1

View File

@@ -155,7 +155,7 @@ odoo.define("web_drop_target", function (require) {
const abstractAction = this.findAncestor(function (ancestor) {
return ancestor instanceof AbstractAction;
});
const controller = abstractAction.currentDialogController;
const controller = abstractAction && abstractAction.currentDialogController;
if (
_.isEmpty(this._get_drop_items(ev)) &&
this._checkDragOver() &&
@@ -186,7 +186,9 @@ odoo.define("web_drop_target", function (require) {
*/
_onBodyFileDrop: function (ev) {
ev.preventDefault();
this._drop_overlay.addClass("d-none");
if (this._drop_overlay) {
this._drop_overlay.addClass("d-none");
}
},
/**