diff --git a/app/assets/javascripts/app/lib/base/jquery.textmodule.js b/app/assets/javascripts/app/lib/base/jquery.textmodule.js index 718fe7c5d..37f4a38c7 100644 --- a/app/assets/javascripts/app/lib/base/jquery.textmodule.js +++ b/app/assets/javascripts/app/lib/base/jquery.textmodule.js @@ -163,8 +163,11 @@ e.keyCode = e.which = keyCode; } - // shift - if (e.keyCode === 16) return + // ignore invalid key codes if search is opened (issue #3637) + if (this.isActive() && e.keyCode === undefined) return + + // skip on shift + arrow_keys + if (_.contains([16, 37, 38, 39, 40], e.keyCode)) return // enter if (e.keyCode === 13) { @@ -172,9 +175,6 @@ return } - // arrow keys - if (e.keyCode === 37 || e.keyCode === 38 || e.keyCode === 39 || e.keyCode === 40) return - var newChar = String.fromCharCode(e.which) // observe other keys diff --git a/spec/system/examples/text_modules_examples.rb b/spec/system/examples/text_modules_examples.rb index d61e86597..7d2640eba 100644 --- a/spec/system/examples/text_modules_examples.rb +++ b/spec/system/examples/text_modules_examples.rb @@ -30,6 +30,16 @@ RSpec.shared_examples 'text modules' do |path:| end end + it 'does not break search on backspace' do + visit path + within(:active_content) do + find('select[name="group_id"]').select(1) + find(:richtext).send_keys('@@agen') + find(:richtext).send_keys(:backspace) + expect(page).to have_no_text('No results found') + end + end + it 'supports group-dependent text modules' do # give user access to all groups including those created