diff --git a/src/canvas.class.js b/src/canvas.class.js index 1fe1fb1eef4..39964f2cb51 100644 --- a/src/canvas.class.js +++ b/src/canvas.class.js @@ -413,8 +413,20 @@ */ _onObjectRemoved: function (obj) { this._objectsToRender = undefined; + // removing active object should fire "selection:cleared" events + if (obj === this._activeObject) { + this.fire('before:selection:cleared', { target: obj }); + this._discardActiveObject(); + this.fire('selection:cleared', { target: obj }); + obj.fire('deselected'); + } + if (obj === this._hoveredTarget) { + this._hoveredTarget = null; + this._hoveredTargets = []; + } this.callSuper('_onObjectRemoved', obj); }, + /** * Divides objects in two groups, one to render immediately * and one to render as activeGroup. @@ -1116,25 +1128,6 @@ return []; }, - /** - * @private - * @param {fabric.Object} obj Object that was removed - */ - _onObjectRemoved: function(obj) { - // removing active object should fire "selection:cleared" events - if (obj === this._activeObject) { - this.fire('before:selection:cleared', { target: obj }); - this._discardActiveObject(); - this.fire('selection:cleared', { target: obj }); - obj.fire('deselected'); - } - if (obj === this._hoveredTarget){ - this._hoveredTarget = null; - this._hoveredTargets = []; - } - this.callSuper('_onObjectRemoved', obj); - }, - /** * @private * Compares the old activeObject with the current one and fires correct events