From ca5ed77b431c5da89036547abd32b7abb959823d Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 22 Nov 2016 14:34:41 -0500 Subject: [PATCH] FIX: More robust `afterRender` for the composer --- .../discourse/components/composer-body.js.es6 | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/app/assets/javascripts/discourse/components/composer-body.js.es6 b/app/assets/javascripts/discourse/components/composer-body.js.es6 index 8c8ddf6e097..ec3bc602cd6 100644 --- a/app/assets/javascripts/discourse/components/composer-body.js.es6 +++ b/app/assets/javascripts/discourse/components/composer-body.js.es6 @@ -28,27 +28,27 @@ export default Ember.Component.extend({ }, @observes('composeState', 'composer.action') - resize() { - Ember.run.scheduleOnce('afterRender', () => { - const h = $('#reply-control').height() || 0; - this.movePanels(h + "px"); + resize() { + Ember.run.scheduleOnce('afterRender', () => { + if (!this.element || this.isDestroying || this.isDestroyed) { return; } - // Figure out the size of the fields - const $fields = this.$('.composer-fields'); - if ($fields) { - const fieldPos = $fields.position(); - if (fieldPos) { - this.$('.wmd-controls').css('top', $fields.height() + fieldPos.top + 5); - } - } + const h = $('#reply-control').height() || 0; + this.movePanels(h + "px"); - // get the submit panel height - const submitPos = this.$('.submit-panel').position(); - if (submitPos) { - this.$('.wmd-controls').css('bottom', h - submitPos.top + 7); - } - }); - }, + // Figure out the size of the fields + const $fields = this.$('.composer-fields'); + const fieldPos = $fields.position(); + if (fieldPos) { + this.$('.wmd-controls').css('top', $fields.height() + fieldPos.top + 5); + } + + // get the submit panel height + const submitPos = this.$('.submit-panel').position(); + if (submitPos) { + this.$('.wmd-controls').css('bottom', h - submitPos.top + 7); + } + }); + }, keyUp() { this.sendAction('typed');