You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The error is not catchable in the @action handlers because the error prevents that action from being sent, so the only workaround is to monkey patch the DraggableObjectTarget component.
One workaround is to extend DraggableObjectTarget with:
importDraggableObjectTargetfrom'ember-drag-drop/components/draggable-object-target';functionisNoObjForKeyError(error){returnerror&&error.message&&error.message.startsWith("no obj for key ");}exportdefaultDraggableObjectTarget.extend({// See https://github.com/mharris717/ember-drag-drop/blob/v0.9.0-beta.0/addon/components/draggable-object-target.js#L22-L25handlePayload(payload,event){letobj;try{obj=this.get('coordinator').getObject(payload,{target: this});}catch(error){if(isNoObjForKeyError(error)){// Intentionally suppress this error so it doesn't throw on non-object// drops (e.g. if you drag and drop text instead of a draggable object)}else{throwerror;}}if(obj){this.get('action')(obj,{target: this,event: event});}}});
An alternative would be to send the action even if obj is null or undefined, for those of you who want to accept non-object drops.
The text was updated successfully, but these errors were encountered:
Drag and drop actions throw an error if the payload being dropped is not a draggable object, such as if it is a text node being dragged.
This same error is reproduced in various other ways in these issues:
#157
#101
#21
#62
And previously this was "fixed" but not completely, in:
https://github.com/mharris717/ember-drag-drop/pull/96/files
The error is not catchable in the
@action
handlers because the error prevents that action from being sent, so the only workaround is to monkey patch the DraggableObjectTarget component.One workaround is to extend DraggableObjectTarget with:
An alternative would be to send the action even if
obj
isnull
orundefined
, for those of you who want to accept non-object drops.The text was updated successfully, but these errors were encountered: