Defect #37473
Focus IssueId when linking issues
Status: | Confirmed | Start date: | ||
---|---|---|---|---|
Priority: | Normal | Due date: | ||
Assignee: | - | % Done: | 0% | |
Category: | Issues | |||
Target version: | 4.2.8 | |||
Resolution: | Affected version: | 4.2.7 |
Description
When I click on the add link in the linked issues section of an issue, the kind Combo and the IssueNumber edit are displayed. Before (can't remember if 5.0.0 or 4.X), the Edit received focus, so that I could just type in issue number directly after clicking Add. Now, I must manually clic in the Edit before typing.
(the captions may be wrong as I am in french translation)
History
#1
Updated by Go MAEDA 27 days ago
- Status changed from New to Confirmed
- Affected version changed from 5.0.2 to 4.2.7
Alexandre Guilleme wrote:
Before (can't remember if 5.0.0 or 4.X), the Edit received focus, so that I could just type in issue number directly after clicking Add. Now, I must manually clic in the Edit before typing.
I have confirmed the issue. Redmine 4.1.7 works as described but Redmine 4.2.7 and 5.0.2 don't.
#2
Updated by Mizuki ISHIKAWA 22 days ago
- You cannot programmatically focus an element after you have attempted to focus it while it was hidden (display:none) https://github.com/jquery/jquery/issues/4950
- You cannot programmatically focus an element after removing its focus handler https://github.com/jquery/jquery/issues/4867
- => The milestone for this issue is 3.6.1, so it will likely be resolved after 3.6.1 is released!
Even with jQuery 3.6.0, the problem does not seem to occur if the code is changed to focus only when the focus target is :visible, as in the following diff.
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index e2eebfa412..95975cdd78 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -335,7 +335,7 @@ module ApplicationHelper
def toggle_link(name, id, options={})
onclick = +"$('##{id}').toggle(); "
- onclick << (options[:focus] ? "$('##{options[:focus]}').focus(); " : "this.blur(); ")
+ onclick << (options[:focus] ? "$('##{options[:focus]}:visible').focus(); " : "this.blur(); ")
onclick << "$(window).scrollTop($('##{options[:focus]}').position().top); " if options[:scroll]
onclick << "return false;"
link_to(name, "#", :onclick => onclick)
diff --git a/public/javascripts/application.js b/public/javascripts/application.js
index 91da192290..4d039cde12 100644
--- a/public/javascripts/application.js
+++ b/public/javascripts/application.js
@@ -958,7 +958,7 @@ function addFormObserversForDoubleSubmit() {
function defaultFocus(){
if (($('#content :focus').length == 0) && (window.location.hash == '')) {
- $('#content input[type=text], #content textarea').first().focus();
+ $('#content input[type=text]:visible, #content textarea:visible').first().focus();
}
}