mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 13:30:55 +01:00
Immediately cancel autocomplete if the user types certain characters anywhere
Summary: Ref T10163. Some characters are almost certainly punctuation or markup rather than autocomplete requests. Immediately cancel any active autocomplete when the user types one of these. Note that some of these are also suffix characters. If you type `@dog,`, you have until the next character to decide you actually mean to autocomplete. Once you type something else we deactivate. If you type `#dog#` or `##`, we deactivate immediately. Test Plan: Typed `@dog#`, etc. Reviewers: chad Reviewed By: chad Maniphest Tasks: T10163 Differential Revision: https://secure.phabricator.com/D15036
This commit is contained in:
parent
df272dfa26
commit
4f3a9a8aca
2 changed files with 27 additions and 9 deletions
|
@ -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' => '3601bdd1',
|
||||
'rsrc/js/phuix/PHUIXAutocomplete.js' => '569edc21',
|
||||
'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' => '3601bdd1',
|
||||
'phuix-autocomplete' => '569edc21',
|
||||
'phuix-dropdown-menu' => 'bd4c8dca',
|
||||
'phuix-form-control-view' => '8fba1997',
|
||||
'phuix-icon-view' => 'bff6884b',
|
||||
|
@ -1064,12 +1064,6 @@ return array(
|
|||
'javelin-vector',
|
||||
'phuix-autocomplete',
|
||||
),
|
||||
'3601bdd1' => array(
|
||||
'javelin-install',
|
||||
'javelin-dom',
|
||||
'phuix-icon-view',
|
||||
'phabricator-prefab',
|
||||
),
|
||||
'3ab51e2c' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-behavior-device',
|
||||
|
@ -1210,6 +1204,12 @@ return array(
|
|||
'javelin-vector',
|
||||
'javelin-dom',
|
||||
),
|
||||
'569edc21' => array(
|
||||
'javelin-install',
|
||||
'javelin-dom',
|
||||
'phuix-icon-view',
|
||||
'phabricator-prefab',
|
||||
),
|
||||
'56a1ca03' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-behavior-device',
|
||||
|
|
|
@ -276,7 +276,13 @@ JX.install('PHUIXAutocomplete', {
|
|||
},
|
||||
|
||||
_getSuffixes: function() {
|
||||
return[' ', ':', ','];
|
||||
return [' ', ':', ',', ')'];
|
||||
},
|
||||
|
||||
_getCancelCharacters: function() {
|
||||
// The "." character does not cancel because of projects named
|
||||
// "node.js" or "blog.mycompany.com".
|
||||
return ['#', '@', ',', '!', '?'];
|
||||
},
|
||||
|
||||
_trim: function(str) {
|
||||
|
@ -392,6 +398,18 @@ JX.install('PHUIXAutocomplete', {
|
|||
|
||||
var trim = this._trim(text);
|
||||
|
||||
// Deactivate immediately if a user types a character that we are
|
||||
// reasonably sure means they don't want to use the autocomplete. For
|
||||
// example, "##" is almost certainly a header or monospaced text, not
|
||||
// a project autocompletion.
|
||||
var cancels = this._getCancelCharacters();
|
||||
for (var ii = 0; ii < cancels.length; ii++) {
|
||||
if (trim.indexOf(cancels[ii]) !== -1) {
|
||||
this._deactivate();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this._datasource.didChange(trim);
|
||||
|
||||
var node = this._getNode();
|
||||
|
|
Loading…
Reference in a new issue