From 942114b34cdff4aca2515470034e98d5b19c9007 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Thu, 27 Dec 2018 23:38:01 +0100 Subject: [PATCH] FIX: optimize collapse/expand select-kit codepath (#6818) --- .../select-kit/mixins/dom-helpers.js.es6 | 21 ++++++++++++------- .../common/select-kit/select-kit.scss | 2 ++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/select-kit/mixins/dom-helpers.js.es6 b/app/assets/javascripts/select-kit/mixins/dom-helpers.js.es6 index edfd3000ea0..7d2c2473c75 100644 --- a/app/assets/javascripts/select-kit/mixins/dom-helpers.js.es6 +++ b/app/assets/javascripts/select-kit/mixins/dom-helpers.js.es6 @@ -63,11 +63,6 @@ export default Ember.Mixin.create({ return this.$(this.filterInputSelector); }, - @on("didRender") - _schedulePositionRendering() { - Ember.run.debounce(this, this._adjustPosition, 50, true); - }, - _adjustPosition() { this._applyDirection(); this._applyFixedPosition(); @@ -128,15 +123,27 @@ export default Ember.Mixin.create({ }); this.focusFilterOrHeader(); this.autoHighlight(); - this._boundaryActionHandler("onExpand", this); + + Ember.run.next(() => { + this._boundaryActionHandler("onExpand", this); + Ember.run.schedule("afterRender", () => { + if (!this.isDestroying && !this.isDestroyed) { + this._adjustPosition(); + } + }); + }); }, collapse() { this.set("isExpanded", false); Ember.run.next(() => { - Ember.run.schedule("afterRender", () => this._removeFixedPosition()); this._boundaryActionHandler("onCollapse", this); + Ember.run.schedule("afterRender", () => { + if (!this.isDestroying && !this.isDestroyed) { + this._removeFixedPosition(); + } + }); }); }, diff --git a/app/assets/stylesheets/common/select-kit/select-kit.scss b/app/assets/stylesheets/common/select-kit/select-kit.scss index f70e9c9da0f..a1a9a2bffc5 100644 --- a/app/assets/stylesheets/common/select-kit/select-kit.scss +++ b/app/assets/stylesheets/common/select-kit/select-kit.scss @@ -24,6 +24,8 @@ z-index: z("dropdown"); .select-kit-body { + -webkit-animation: fadein 0.25s; + animation: fadein 0.25s; display: flex; flex-direction: column; left: 0;