1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 01:08:50 +02:00

When the autocompleter would fall off the bottom of the screen, put it above the text instead

Summary: Ref T10163. In cases like Conpherence, the autocompleter can currently render off the bottom of the screen. Put it above if it would be offscreen.

Test Plan: {F1062286}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10163

Differential Revision: https://secure.phabricator.com/D15038
This commit is contained in:
epriestley 2016-01-16 14:00:02 -08:00
parent 14ebf662f3
commit 849b4c765a
2 changed files with 28 additions and 10 deletions

View file

@ -507,7 +507,7 @@ return array(
'rsrc/js/phui/behavior-phui-object-box-tabs.js' => '2bfa2836',
'rsrc/js/phuix/PHUIXActionListView.js' => 'b5c256b8',
'rsrc/js/phuix/PHUIXActionView.js' => '8cf6d262',
'rsrc/js/phuix/PHUIXAutocomplete.js' => '377c9b3e',
'rsrc/js/phuix/PHUIXAutocomplete.js' => '5582787f',
'rsrc/js/phuix/PHUIXDropdownMenu.js' => 'bd4c8dca',
'rsrc/js/phuix/PHUIXFormControl.js' => '8fba1997',
'rsrc/js/phuix/PHUIXIconView.js' => 'bff6884b',
@ -836,7 +836,7 @@ return array(
'phui-workpanel-view-css' => 'adec7699',
'phuix-action-list-view' => 'b5c256b8',
'phuix-action-view' => '8cf6d262',
'phuix-autocomplete' => '377c9b3e',
'phuix-autocomplete' => '5582787f',
'phuix-dropdown-menu' => 'bd4c8dca',
'phuix-form-control-view' => '8fba1997',
'phuix-icon-view' => 'bff6884b',
@ -1064,12 +1064,6 @@ return array(
'javelin-vector',
'phuix-autocomplete',
),
'377c9b3e' => array(
'javelin-install',
'javelin-dom',
'phuix-icon-view',
'phabricator-prefab',
),
'3ab51e2c' => array(
'javelin-behavior',
'javelin-behavior-device',
@ -1204,6 +1198,12 @@ return array(
'javelin-request',
'javelin-typeahead-source',
),
'5582787f' => array(
'javelin-install',
'javelin-dom',
'phuix-icon-view',
'phabricator-prefab',
),
'558829c2' => array(
'javelin-stratcom',
'javelin-behavior',

View file

@ -232,6 +232,8 @@ JX.install('PHUIXAutocomplete', {
if (this._focus === null && nodes.length) {
this._setFocus(0);
}
this._redraw();
},
_setFocus: function(idx) {
@ -440,9 +442,25 @@ JX.install('PHUIXAutocomplete', {
}
var node = this._getNode();
node.style.left = this._x + 'px';
node.style.top = this._y + 'px';
JX.DOM.show(node);
var p = new JX.Vector(this._x, this._y);
var s = JX.Vector.getScroll();
var v = JX.Vector.getViewport();
// If the menu would run off the bottom of the screen when showing the
// maximum number of possible choices, put it above instead. We're doing
// this based on the maximum size so the menu doesn't jump up and down
// as results arrive.
var option_height = 30;
var extra_margin = 24;
if ((s.y + v.y) < (p.y + (5 * option_height) + extra_margin)) {
var d = JX.Vector.getDim(node);
p.y = p.y - d.y - 36;
}
p.setPos(node);
},
_autocomplete: function() {