Fix positioning of mention dropdown

Previously, the positioning logic did not account for the case
when the textarea was already scrolled down a bit, thus often
rendering the dropdown off-screen.

Fixes flarum/core#1021.
This commit is contained in:
Franz Liedke 2018-07-23 14:27:21 +02:00
parent 8214638cb5
commit 2e9c184b3b

View File

@ -153,9 +153,9 @@ export default function addComposerAutocomplete() {
const height = dropdown.$().outerHeight();
const parent = dropdown.$().offsetParent();
let left = coordinates.left;
let top = coordinates.top + 15;
let top = coordinates.top - this.scrollTop + 15;
if (top + height > parent.height()) {
top = coordinates.top - height - 15;
top = coordinates.top - this.scrollTop - height - 15;
}
if (left + width > parent.width()) {
left = parent.width() - width;