Skip to content

A platform for community discussion. Free, open, simple.

FIX: makes more resilient select-kit positioning (#6776)

Joffrey JAFFEUXd803dfc14ac7
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 d490fa0abed..b6a4fdf64fc 100644
--- a/app/assets/javascripts/select-kit/mixins/dom-helpers.js.es6
+++ b/app/assets/javascripts/select-kit/mixins/dom-helpers.js.es6
@@ -64,6 +64,10 @@ export default Ember.Mixin.create({
},
@on("didRender")
+ _schedulePositionRendering() {
+ Ember.run.debounce(this, this._adjustPosition, 50, true);
+ },
+
_adjustPosition() {
this._applyFixedPosition();
this._applyDirection();
@@ -205,9 +209,10 @@ export default Ember.Mixin.create({
const fullHeight =
this.get("verticalOffset") + bodyHeight + componentHeight;
- const hasBelowSpace = $(window).height() - offsetBottom - fullHeight > 0;
- const hasAboveSpace = offsetTop - fullHeight - discourseHeaderHeight > 0;
+ const hasBelowSpace = $(window).height() - offsetBottom - fullHeight >= -1;
+ const hasAboveSpace = offsetTop - fullHeight - discourseHeaderHeight >= -1;
const headerHeight = this._computedStyle(this.$header()[0], "height");
+
if (hasBelowSpace || (!hasBelowSpace && !hasAboveSpace)) {
this.setProperties({ isBelow: true, isAbove: false });
options.top = headerHeight + this.get("verticalOffset");