From c5757e9afb29f094a37e3ac19f22db4b90fc7670 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Wed, 28 Dec 2016 10:19:24 +0000 Subject: [PATCH] Fix GFM dropdown not showing at beginning of new lines Closes #26145 --- app/assets/javascripts/gfm_auto_complete.js.es6 | 2 +- changelogs/unreleased/gfm-new-line-fix.yml | 4 ++++ spec/features/issues/gfm_autocomplete_spec.rb | 12 ++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/gfm-new-line-fix.yml diff --git a/app/assets/javascripts/gfm_auto_complete.js.es6 b/app/assets/javascripts/gfm_auto_complete.js.es6 index 3857bbb743b..87c579ac757 100644 --- a/app/assets/javascripts/gfm_auto_complete.js.es6 +++ b/app/assets/javascripts/gfm_auto_complete.js.es6 @@ -77,7 +77,7 @@ var _a, _y, regexp, match, atSymbolsWithBar, atSymbolsWithoutBar; atSymbolsWithBar = Object.keys(this.app.controllers).join('|'); atSymbolsWithoutBar = Object.keys(this.app.controllers).join(''); - subtext = subtext.split(' ').pop(); + subtext = subtext.split(/\s+/g).pop(); flag = flag.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); _a = decodeURI("%C3%80"); diff --git a/changelogs/unreleased/gfm-new-line-fix.yml b/changelogs/unreleased/gfm-new-line-fix.yml new file mode 100644 index 00000000000..751bb356b5f --- /dev/null +++ b/changelogs/unreleased/gfm-new-line-fix.yml @@ -0,0 +1,4 @@ +--- +title: Fixed GFM dropdown not showing on new lines +merge_request: +author: diff --git a/spec/features/issues/gfm_autocomplete_spec.rb b/spec/features/issues/gfm_autocomplete_spec.rb index 3489331a1b6..82c9bd0e6e6 100644 --- a/spec/features/issues/gfm_autocomplete_spec.rb +++ b/spec/features/issues/gfm_autocomplete_spec.rb @@ -47,6 +47,18 @@ feature 'GFM autocomplete', feature: true, js: true do expect_to_wrap(true, label_item, note, label.title) end + it "shows dropdown after a new line" do + note = find('#note_note') + page.within '.timeline-content-form' do + note.native.send_keys('test') + note.native.send_keys(:enter) + note.native.send_keys(:enter) + note.native.send_keys('@') + end + + expect(page).to have_selector('.atwho-container') + end + it "does not show dropdown when preceded with a special character" do note = find('#note_note') page.within '.timeline-content-form' do