mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
Fix autocomplete/send-on-enter interactions
Summary: Send-on-enter and autocomplete both listen for "return" keypresses, and could race. Have autocomplete let other handlers take a shot at the action before it does. Also, fix a case where ":)" and the suffix list (which lets you type `someone is 100% to blame here (@epriestley)` and get the results you want) interacted badly, so ":)" cancels the autocompleter like ":3" does. Test Plan: - Typed "@xxx" and mashed return real fast over and over again while reloading the page. Before: sometimes handlers raced and text submitted. After: always handled by autocomplete behavior. - Typed ":", ")", "<return>", sent an emoticon (previously: no). Reviewers: chad, amckinley Reviewed By: chad Subscribers: xxx Differential Revision: https://secure.phabricator.com/D17794
This commit is contained in:
parent
7824710522
commit
adb1d3a5be
2 changed files with 14 additions and 5 deletions
|
@ -393,6 +393,12 @@ JX.behavior('phabricator-remarkup-assist', function(config) {
|
|||
return;
|
||||
}
|
||||
|
||||
// Let other listeners (particularly the inline autocomplete) have a
|
||||
// chance to handle this event.
|
||||
if (JX.Stratcom.pass()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var raw = e.getRawEvent();
|
||||
if (raw.shiftKey) {
|
||||
// If the shift key is pressed, let the browser write a newline into
|
||||
|
@ -412,8 +418,7 @@ JX.behavior('phabricator-remarkup-assist', function(config) {
|
|||
// This allows 'workflow' and similar actions to take effect.
|
||||
// Such as pontificate in Conpherence
|
||||
var form = e.getNode('tag:form');
|
||||
var r = JX.DOM.invoke(form, 'didSyntheticSubmit');
|
||||
|
||||
JX.DOM.invoke(form, 'didSyntheticSubmit');
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ JX.install('PHUIXAutocomplete', {
|
|||
}
|
||||
|
||||
// Get all the text on the current line. If the line only contains
|
||||
// whitespace, don't actiavte: the user is probably typing code or a
|
||||
// whitespace, don't activate: the user is probably typing code or a
|
||||
// numbered list.
|
||||
var line = area.value.substring(0, head - 1);
|
||||
line = line.split('\n');
|
||||
|
@ -454,7 +454,7 @@ JX.install('PHUIXAutocomplete', {
|
|||
|
||||
// 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
|
||||
// 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();
|
||||
|
@ -529,9 +529,13 @@ JX.install('PHUIXAutocomplete', {
|
|||
}
|
||||
}
|
||||
|
||||
// Deactivate immediately if the user types an ignored token like ":)",
|
||||
// the smiley face emoticon. Note that we test against "text", not
|
||||
// "trim", because the ignore list and suffix list can otherwise
|
||||
// interact destructively.
|
||||
var ignore = this._getIgnoreList();
|
||||
for (ii = 0; ii < ignore.length; ii++) {
|
||||
if (trim.indexOf(ignore[ii]) === 0) {
|
||||
if (text.indexOf(ignore[ii]) === 0) {
|
||||
this._deactivate();
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue