summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilipa Lacerda <lacerda.filipa@gmail.com>2017-02-17 10:41:46 +0000
committerFelipe Artur <felipefac@gmail.com>2017-02-17 18:00:34 -0200
commit755745e86029830a3f23154d9e6e5bc9f22251b5 (patch)
tree9218c8a3f72bf9ddee679bd87e3885fce0f57d47
parentd0d5dc8fe056c5559c57b51f5543d96a24c5ee46 (diff)
downloadgitlab-ce-755745e86029830a3f23154d9e6e5bc9f22251b5.tar.gz
Merge branch '27883-autocomplete-seems-to-not-trigger-when-at-character-is-part-of-an-autocompleted-text' into 'master'
Trigger at.js after selecting slash commands with autocomplete suffix Closes #27883 See merge request !9117
-rw-r--r--app/assets/javascripts/gfm_auto_complete.js.es63
-rw-r--r--changelogs/unreleased/27883-autocomplete-seems-to-not-trigger-when-at-character-is-part-of-an-autocompleted-text.yml4
-rw-r--r--spec/features/issues/gfm_autocomplete_spec.rb14
3 files changed, 21 insertions, 0 deletions
diff --git a/app/assets/javascripts/gfm_auto_complete.js.es6 b/app/assets/javascripts/gfm_auto_complete.js.es6
index 7f1f2a5d278..0f6994dd2d1 100644
--- a/app/assets/javascripts/gfm_auto_complete.js.es6
+++ b/app/assets/javascripts/gfm_auto_complete.js.es6
@@ -103,6 +103,9 @@
this.input.each((i, input) => {
const $input = $(input);
$input.off('focus.setupAtWho').on('focus.setupAtWho', this.setupAtWho.bind(this, $input));
+ // This triggers at.js again
+ // Needed for slash commands with suffixes (ex: /label ~)
+ $input.on('inserted-commands.atwho', $input.trigger.bind($input, 'keyup'));
});
},
setupAtWho: function($input) {
diff --git a/changelogs/unreleased/27883-autocomplete-seems-to-not-trigger-when-at-character-is-part-of-an-autocompleted-text.yml b/changelogs/unreleased/27883-autocomplete-seems-to-not-trigger-when-at-character-is-part-of-an-autocompleted-text.yml
new file mode 100644
index 00000000000..52b7e96682d
--- /dev/null
+++ b/changelogs/unreleased/27883-autocomplete-seems-to-not-trigger-when-at-character-is-part-of-an-autocompleted-text.yml
@@ -0,0 +1,4 @@
+---
+title: Trigger autocomplete after selecting a slash command
+merge_request: 9117
+author:
diff --git a/spec/features/issues/gfm_autocomplete_spec.rb b/spec/features/issues/gfm_autocomplete_spec.rb
index 93139dc9e94..7135565294b 100644
--- a/spec/features/issues/gfm_autocomplete_spec.rb
+++ b/spec/features/issues/gfm_autocomplete_spec.rb
@@ -182,6 +182,20 @@ feature 'GFM autocomplete', feature: true, js: true do
expect(page).not_to have_selector('.atwho-view')
end
+ it 'triggers autocomplete after selecting a slash command' do
+ note = find('#note_note')
+ page.within '.timeline-content-form' do
+ note.native.send_keys('')
+ note.native.send_keys('/as')
+ note.click
+ end
+
+ find('.atwho-view li', text: '/assign').native.send_keys(:tab)
+
+ user_item = find('.atwho-view li', text: user.username)
+ expect(user_item).to have_content(user.username)
+ end
+
def expect_to_wrap(should_wrap, item, note, value)
expect(item).to have_content(value)
expect(item).not_to have_content("\"#{value}\"")