mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
Immediately deactivate remarkup autocomplete if there's no query
Summary: Fixes T12479. If you end a line with a character like ":" in a context which can trigger autocomplete (e.g., `.:`), then try to make a newline, we swallow the keystroke. Instead, allow the keystroke through if the user hasn't typed anything else yet. Test Plan: - Autocompleted emoji and users normally. - In an empty textarea, typed `.:<return>`, got a newline instead of a swallowed keystroke. Reviewers: chad Reviewed By: chad Maniphest Tasks: T12479 Differential Revision: https://secure.phabricator.com/D17583
This commit is contained in:
parent
cb1d904654
commit
130ebd2c42
2 changed files with 27 additions and 18 deletions
|
@ -528,7 +528,7 @@ return array(
|
|||
'rsrc/js/phui/behavior-phui-tab-group.js' => '0a0b10e9',
|
||||
'rsrc/js/phuix/PHUIXActionListView.js' => 'b5c256b8',
|
||||
'rsrc/js/phuix/PHUIXActionView.js' => 'b3465b9b',
|
||||
'rsrc/js/phuix/PHUIXAutocomplete.js' => '7910aacb',
|
||||
'rsrc/js/phuix/PHUIXAutocomplete.js' => 'd5b2abf3',
|
||||
'rsrc/js/phuix/PHUIXDropdownMenu.js' => '8018ee50',
|
||||
'rsrc/js/phuix/PHUIXFormControl.js' => '83e03671',
|
||||
'rsrc/js/phuix/PHUIXIconView.js' => 'bff6884b',
|
||||
|
@ -885,7 +885,7 @@ return array(
|
|||
'phui-workpanel-view-css' => 'a3a63478',
|
||||
'phuix-action-list-view' => 'b5c256b8',
|
||||
'phuix-action-view' => 'b3465b9b',
|
||||
'phuix-autocomplete' => '7910aacb',
|
||||
'phuix-autocomplete' => 'd5b2abf3',
|
||||
'phuix-dropdown-menu' => '8018ee50',
|
||||
'phuix-form-control-view' => '83e03671',
|
||||
'phuix-icon-view' => 'bff6884b',
|
||||
|
@ -1456,12 +1456,6 @@ return array(
|
|||
'multirow-row-manager',
|
||||
'javelin-json',
|
||||
),
|
||||
'7910aacb' => array(
|
||||
'javelin-install',
|
||||
'javelin-dom',
|
||||
'phuix-icon-view',
|
||||
'phabricator-prefab',
|
||||
),
|
||||
'7927a7d3' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-quicksand',
|
||||
|
@ -2053,6 +2047,12 @@ return array(
|
|||
'javelin-uri',
|
||||
'phabricator-notification',
|
||||
),
|
||||
'd5b2abf3' => array(
|
||||
'javelin-install',
|
||||
'javelin-dom',
|
||||
'phuix-icon-view',
|
||||
'phabricator-prefab',
|
||||
),
|
||||
'd6a7e717' => array(
|
||||
'multirow-row-manager',
|
||||
'javelin-install',
|
||||
|
|
|
@ -433,6 +433,16 @@ JX.install('PHUIXAutocomplete', {
|
|||
}
|
||||
}
|
||||
|
||||
// Deactivate if the user moves the cursor to the left of the assist
|
||||
// range. For example, they might press the "left" arrow to move the
|
||||
// cursor to the left, or click in the textarea prior to the active
|
||||
// range.
|
||||
var range = JX.TextAreaUtils.getSelectionRange(area);
|
||||
if (range.start < this._cursorHead) {
|
||||
this._deactivate();
|
||||
return;
|
||||
}
|
||||
|
||||
if (special == 'tab' || special == 'return') {
|
||||
var r = e.getRawEvent();
|
||||
if (r.shiftKey && special == 'tab') {
|
||||
|
@ -443,6 +453,15 @@ JX.install('PHUIXAutocomplete', {
|
|||
return;
|
||||
}
|
||||
|
||||
// If the user hasn't typed any text yet after typing the character
|
||||
// which can summon the autocomplete, deactivate and let the keystroke
|
||||
// through. For example, We hit this when a line ends with an
|
||||
// autocomplete character and the user is trying to type a newline.
|
||||
if (range.start == this._cursorHead) {
|
||||
this._deactivate();
|
||||
return;
|
||||
}
|
||||
|
||||
// If we autocomplete, we're done. Otherwise, just eat the event. This
|
||||
// happens if you type too fast and try to tab complete before results
|
||||
// load.
|
||||
|
@ -454,16 +473,6 @@ JX.install('PHUIXAutocomplete', {
|
|||
return;
|
||||
}
|
||||
|
||||
// Deactivate if the user moves the cursor to the left of the assist
|
||||
// range. For example, they might press the "left" arrow to move the
|
||||
// cursor to the left, or click in the textarea prior to the active
|
||||
// range.
|
||||
var range = JX.TextAreaUtils.getSelectionRange(area);
|
||||
if (range.start < this._cursorHead) {
|
||||
this._deactivate();
|
||||
return;
|
||||
}
|
||||
|
||||
// Deactivate if the user moves the cursor to the right of the assist
|
||||
// range. For example, they might click later in the document. If the user
|
||||
// is pressing the "right" arrow key, they are not allowed to move the
|
||||
|
|
Loading…
Reference in a new issue