Skip to content

Commit

Permalink
Detect if mention panel goes beyond window borders.
Browse files Browse the repository at this point in the history
  • Loading branch information
hub33k committed Sep 8, 2020
1 parent 3cf0051 commit b774464
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions plugins/autocomplete/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,13 @@
top = Math.max( rect.bottom, editorViewportRect.top );
}

var windowHeight = window.innerHeight || Math.max( document.body.offsetHeight, document.documentElement.offsetHeight );

// Detect if panel goes beyond window borders.
if ( rect.top + viewHeight > windowHeight ) {
top = rect.top - viewHeight;
}

this.element.setStyles( {
left: rect.left + 'px',
top: top + 'px'
Expand Down

0 comments on commit b774464

Please sign in to comment.