From 5d2aa957b4ce0a99cedb8f3f9ef37bff64522657 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Thu, 22 Sep 2016 13:42:49 +0800 Subject: [PATCH] UX: Take into account of header when rendering autocomplete. --- .../discourse/lib/autocomplete.js.es6 | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/discourse/lib/autocomplete.js.es6 b/app/assets/javascripts/discourse/lib/autocomplete.js.es6 index 10bc508b1..9509b4622 100644 --- a/app/assets/javascripts/discourse/lib/autocomplete.js.es6 +++ b/app/assets/javascripts/discourse/lib/autocomplete.js.es6 @@ -237,15 +237,19 @@ export default function(options) { me.parent().append(div); - if(!isInput){ + if (!isInput) { vOffset = div.height(); - } - if (Discourse.Site.currentProp('mobileView') && !isInput) { - div.css('width', 'auto'); + if ((window.innerHeight - me.outerHeight() - $("header.d-header").innerHeight()) < vOffset) { + vOffset = -23; + } - if ((me.height() / 2) >= pos.top) { vOffset = -23; } - if ((me.width() / 2) <= pos.left) { hOffset = -div.width(); } + if (Discourse.Site.currentProp('mobileView')) { + div.css('width', 'auto'); + + if ((me.height() / 2) >= pos.top) { vOffset = -23; } + if ((me.width() / 2) <= pos.left) { hOffset = -div.width(); } + } } var mePos = me.position();