From 66960bc94b2feb9533a5a35cec3c2a76a237b597 Mon Sep 17 00:00:00 2001 From: ishikawa Date: Thu, 12 May 2022 02:37:07 +0000 Subject: [PATCH] Fix problem with search field not autofocusing in Redmine 5.0 or latar(jquery3.6.0) --- assets/javascripts/searchable_selectbox.js | 6 ++++++ init.rb | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/assets/javascripts/searchable_selectbox.js b/assets/javascripts/searchable_selectbox.js index ac80b14..dedb790 100644 --- a/assets/javascripts/searchable_selectbox.js +++ b/assets/javascripts/searchable_selectbox.js @@ -12,6 +12,12 @@ $(document).on('ajax:success', function() { initAssignToMeLink(); }); +// Fix a problem with focus not working in Redmine 5.0 or later. +// issue: https://github.com/select2/select2/issues/5993 +$(document).on('select2:open', function() { + document.querySelector('.select2-search__field').focus(); +}); + // Override addEventListener to get that there is a native event. EventTarget.prototype._addEventListener = EventTarget.prototype.addEventListener; EventTarget.prototype.addEventListener = function(type, listener, options) { diff --git a/init.rb b/init.rb index 13e50af..7b84e56 100644 --- a/init.rb +++ b/init.rb @@ -4,7 +4,7 @@ Redmine::Plugin.register :redmine_searchable_selectbox do name 'Redmine Searchable Selectbox' description "This plugin changes Redmine's selectbox searchable." - version '0.1.8' + version '0.1.9' settings default: {'enabled' => 1}, partial: 'settings/searchable_selectbox_settings' end