diff options
-rw-r--r-- | app/assets/javascripts/gfm_auto_complete.js.es6 | 2 | ||||
-rw-r--r-- | changelogs/unreleased/label-gfm-error-fix.yml | 4 | ||||
-rw-r--r-- | spec/features/issues/gfm_autocomplete_spec.rb | 13 |
3 files changed, 17 insertions, 2 deletions
diff --git a/app/assets/javascripts/gfm_auto_complete.js.es6 b/app/assets/javascripts/gfm_auto_complete.js.es6 index 12875eaa1c3..3857bbb743b 100644 --- a/app/assets/javascripts/gfm_auto_complete.js.es6 +++ b/app/assets/javascripts/gfm_auto_complete.js.es6 @@ -367,7 +367,7 @@ return $input.trigger('keyup'); }, isLoading(data) { - if (!data) return false; + if (!data || !data.length) return false; if (Array.isArray(data)) data = data[0]; return data === this.defaultLoadingData[0] || data.name === this.defaultLoadingData[0]; }, diff --git a/changelogs/unreleased/label-gfm-error-fix.yml b/changelogs/unreleased/label-gfm-error-fix.yml new file mode 100644 index 00000000000..37f311d4790 --- /dev/null +++ b/changelogs/unreleased/label-gfm-error-fix.yml @@ -0,0 +1,4 @@ +--- +title: Fixed GFM autocomplete error when no data exists +merge_request: +author: diff --git a/spec/features/issues/gfm_autocomplete_spec.rb b/spec/features/issues/gfm_autocomplete_spec.rb index d0294908d2c..3489331a1b6 100644 --- a/spec/features/issues/gfm_autocomplete_spec.rb +++ b/spec/features/issues/gfm_autocomplete_spec.rb @@ -47,7 +47,7 @@ feature 'GFM autocomplete', feature: true, js: true do expect_to_wrap(true, label_item, note, label.title) end - it "does not show drpdown when preceded with a special character" do + it "does not show dropdown when preceded with a special character" do note = find('#note_note') page.within '.timeline-content-form' do note.native.send_keys('') @@ -65,6 +65,17 @@ feature 'GFM autocomplete', feature: true, js: true do expect(page).to have_selector('.atwho-container', visible: false) end + it "does not throw an error if no labels exist" do + note = find('#note_note') + page.within '.timeline-content-form' do + note.native.send_keys('') + note.native.send_keys('~') + note.click + end + + expect(page).to have_selector('.atwho-container', visible: false) + end + it 'doesn\'t wrap for assignee values' do note = find('#note_note') page.within '.timeline-content-form' do |