From b7fe07bbd6fb0bed86e18d6204b26982ac9effb8 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sat, 16 Jan 2016 15:06:15 -0800 Subject: [PATCH] When autocompleting, add a space if a user didn't already add something Summary: Ref T10163. When a user autocompletes, add a space for them, unless they already added a comma, colon, or space themsevles. Test Plan: Autocompleted `@dog`, got `@dog `. Autocompleted `@epriestley,` got `@epriestley,`. Reviewers: chad Reviewed By: chad Maniphest Tasks: T10163 Differential Revision: https://secure.phabricator.com/D15041 --- resources/celerity/map.php | 16 ++++++++-------- webroot/rsrc/js/phuix/PHUIXAutocomplete.js | 9 ++++++++- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 8f22b91818..a41af25a7e 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -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' => '8bbbad27', + 'rsrc/js/phuix/PHUIXAutocomplete.js' => 'fc10c813', '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' => '8bbbad27', + 'phuix-autocomplete' => 'fc10c813', 'phuix-dropdown-menu' => 'bd4c8dca', 'phuix-form-control-view' => '8fba1997', 'phuix-icon-view' => 'bff6884b', @@ -1489,12 +1489,6 @@ return array( 'javelin-stratcom', 'javelin-vector', ), - '8bbbad27' => array( - 'javelin-install', - 'javelin-dom', - 'phuix-icon-view', - 'phabricator-prefab', - ), '8bdb2835' => array( 'phui-fontkit-css', ), @@ -2092,6 +2086,12 @@ return array( 'javelin-behavior-device', 'phabricator-keyboard-shortcut', ), + 'fc10c813' => array( + 'javelin-install', + 'javelin-dom', + 'phuix-icon-view', + 'phabricator-prefab', + ), 'fc91ab6c' => array( 'javelin-behavior', 'javelin-dom', diff --git a/webroot/rsrc/js/phuix/PHUIXAutocomplete.js b/webroot/rsrc/js/phuix/PHUIXAutocomplete.js index b94688e086..beb3660718 100644 --- a/webroot/rsrc/js/phuix/PHUIXAutocomplete.js +++ b/webroot/rsrc/js/phuix/PHUIXAutocomplete.js @@ -600,19 +600,26 @@ JX.install('PHUIXAutocomplete', { return false; } - // If the user types a string like "@username:" (with a trailing comma), + // If the user types a string like "@username:" (with a trailing colon), // then presses tab or return to pick the completion, don't destroy the // trailing character. var suffixes = this._getSuffixes(); var value = this._value; + var found_suffix = false; for (var ii = 0; ii < suffixes.length; ii++) { var last = value.substring(value.length - suffixes[ii].length); if (last == suffixes[ii]) { ref += suffixes[ii]; + found_suffix = true; break; } } + // If we didn't find an existing suffix, add a space. + if (!found_suffix) { + ref = ref + ' '; + } + area.value = text.substring(0, head - 1) + ref + text.substring(tail); var end = head + ref.length;