[FIX] Better header height computation

Prevents the select-box to think there's enough space above (very common when using customised header).
This commit is contained in:
Joffrey JAFFEUX 2017-10-20 14:03:26 -07:00 committed by GitHub
parent 07929be817
commit 2fe2c1bfb9
1 changed files with 4 additions and 2 deletions

View File

@ -340,7 +340,9 @@ export default Ember.Component.extend(UtilsMixin, DomHelpersMixin, KeyboardMixin
_applyDirection() {
let options = { left: "auto", bottom: "auto", top: "auto" };
const discourseHeaderHeight = $(".d-header").outerHeight(false);
const dHeaderBounds = $(".d-header")[0].getBoundingClientRect();
const dHeaderHeight = dHeaderBounds.top + dHeaderBounds.height;
const headerHeight = this.$header().outerHeight(false);
const headerWidth = this.$header().outerWidth(false);
const bodyHeight = this.$body().outerHeight(false);
@ -384,7 +386,7 @@ export default Ember.Component.extend(UtilsMixin, DomHelpersMixin, KeyboardMixin
const componentHeight = this.get("verticalOffset") + bodyHeight + headerHeight;
const hasBelowSpace = windowHeight - offsetBottom - componentHeight > 0;
const hasAboveSpace = offsetTop - componentHeight - discourseHeaderHeight > 0;
const hasAboveSpace = offsetTop - componentHeight - dHeaderHeight > 0;
if (hasBelowSpace || (!hasBelowSpace && !hasAboveSpace)) {
this.setProperties({ isBelow: true, isAbove: false });
options.top = headerHeight + this.get("verticalOffset");