diff --git a/src/commands/view/SelectComponent.js b/src/commands/view/SelectComponent.js index f4408bdf5..896a88709 100644 --- a/src/commands/view/SelectComponent.js +++ b/src/commands/view/SelectComponent.js @@ -95,6 +95,7 @@ export default { this.updateGlobalPos, this ); + em[method]('component:update:toolbar', this._upToolbar, this); em[method]('change:canvasOffset', this.updateAttached, this); em[method]('frame:updated', this.onFrameUpdated, this); em[method]('canvas:updateTools', this.onFrameUpdated, this); @@ -640,7 +641,11 @@ export default { style.height = pos.height + unit; }, - updateToolsGlobal() { + _upToolbar: debounce(function() { + this.updateToolsGlobal({ force: 1 }); + }), + + updateToolsGlobal(opts = {}) { const { el, pos, component } = this.getElSelected(); if (!el) { @@ -652,7 +657,7 @@ export default { const { canvas } = this; const isNewEl = this.lastSelected !== el; - if (isNewEl) { + if (isNewEl || opts.force) { this.lastSelected = el; this.updateToolbar(component); } diff --git a/src/dom_components/model/Component.js b/src/dom_components/model/Component.js index 7b87dbc38..b24b22442 100644 --- a/src/dom_components/model/Component.js +++ b/src/dom_components/model/Component.js @@ -191,6 +191,7 @@ const Component = Backbone.Model.extend(Styleable).extend( this.listenTo(this, 'change:tagName', this.tagUpdated); this.listenTo(this, 'change:attributes', this.attrUpdated); this.listenTo(this, 'change:attributes:id', this._idUpdated); + this.on('change:toolbar', this.__emitUpdateTlb); this.set('status', ''); this.views = []; this.__isSymbol() && this.__initSymb(); @@ -209,6 +210,10 @@ const Component = Backbone.Model.extend(Styleable).extend( } }, + __emitUpdateTlb() { + this.emitUpdate('toolbar'); + }, + /** * Check component's type * @param {string} type Component type