From c8282e4ca1f106487d028e43355163d95a4e835b Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Thu, 3 Nov 2016 13:51:16 -0400 Subject: [PATCH] FIX: We're running code outside of the runloop --- .../javascripts/discourse/components/d-editor.js.es6 | 8 +++++++- .../discourse/components/topic-navigation.js.es6 | 10 +++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/discourse/components/d-editor.js.es6 b/app/assets/javascripts/discourse/components/d-editor.js.es6 index 322959422f8..e6dd2804dde 100644 --- a/app/assets/javascripts/discourse/components/d-editor.js.es6 +++ b/app/assets/javascripts/discourse/components/d-editor.js.es6 @@ -278,7 +278,13 @@ export default Ember.Component.extend({ @observes('ready', 'value') _watchForChanges() { if (!this.get('ready')) { return; } - Ember.run.debounce(this, this._updatePreview, 30); + + // Debouncing in test mode is complicated + if (Ember.testing) { + this._updatePreview(); + } else { + Ember.run.debounce(this, this._updatePreview, 30); + } }, _applyCategoryHashtagAutocomplete(container) { diff --git a/app/assets/javascripts/discourse/components/topic-navigation.js.es6 b/app/assets/javascripts/discourse/components/topic-navigation.js.es6 index 1dd1e812160..579f9959f19 100644 --- a/app/assets/javascripts/discourse/components/topic-navigation.js.es6 +++ b/app/assets/javascripts/discourse/components/topic-navigation.js.es6 @@ -4,7 +4,7 @@ export default Ember.Component.extend({ composerOpen: null, info: Em.Object.create(), - _checkSize() { + _performCheckSize() { if (!this.element || this.isDestroying || this.isDestroyed) { return; } let info = this.get('info'); @@ -39,6 +39,10 @@ export default Ember.Component.extend({ } }, + _checkSize() { + Ember.run.scheduleOnce('afterRender', this, this._performCheckSize); + }, + // we need to store this so topic progress has something to init with _topicScrolled(event) { this.set('info.prevEvent', event); @@ -62,7 +66,7 @@ export default Ember.Component.extend({ composerOpened() { this.set('composerOpen', true); // we need to do the check after animation is done - setTimeout(()=>this._checkSize(), 500); + Ember.run.later(() => this._checkSize(), 500); }, composerClosed() { @@ -112,7 +116,7 @@ export default Ember.Component.extend({ $('#reply-control').on('div-resized.discourse-topic-navigation', () => this._checkSize()); } - Ember.run.scheduleOnce('afterRender', this, this._checkSize); + this._checkSize(); }, willDestroyElement() {