Feature #13134
closedFocus first text field automatically
Added by Harry Garrood over 11 years ago. Updated about 9 years ago.
0%
Description
The attached patch uses JS to focus the Name field in the versions/_form
partial. Based on trunk r11352.
Also I grepped through 'test' for the string 'focus', to see if this kind of stuff is tested, and didn't find anything; hence, no tests.
Files
autofocus_version_name.patch (309 Bytes) autofocus_version_name.patch | Harry Garrood, 2013-02-12 00:59 |
Related issues
Updated by Daniel Felix over 11 years ago
Well I would agree that this would work. But another idea is to use the HTML5 autofocus function, which won't work on older browsers but would work even without js.
The tag could be included on systems with some older browser engine (for example IE7,8,9).
The tag is quite simple:
autofocus="autofocus"
Example:
<input type="text" id="search" autofocus="autofocus" />
Updated by Harry Garrood over 11 years ago
JS seems to makes more sense to me, since:
- Redmine doesn't work without JS anyway -- this patch should work with all Redmine-capable browser setups
- The only IE to support HTML5 autofocus is IE10
- It's consistent; this JS is used in other places in Redmine (eg
issues/new
)
Updated by Daniel Felix over 11 years ago
Harry Garrood wrote:
- Redmine doesn't work without JS anyway -- this patch should work with all Redmine-capable browser setups
Right, it will work. But I personally would use this just as fallback if there is no build-in property. But maybe just my own thinking. :-)
- The only IE to support HTML5 autofocus is IE10
Yes, and all other major Browsers use this.
See: http://www.wufoo.com/html5/attributes/02-autofocus.html
- It's consistent; this JS is used in other places in Redmine (eg
issues/new
)
You're right. But on the other Hand, it would be quite good to be able to use Redmine without any JS, too. :-)
Updated by Jean-Philippe Lang over 11 years ago
Another approach that would prevent autofocus attributes or js in each view would be add a few js lines in application.js to automatically focus the first input[type=text] that is found in the page content. What do you think?
Updated by Daniel Felix over 11 years ago
Jean-Philippe Lang wrote:
Another approach that would prevent autofocus attributes or js in each view would be add a few js lines in application.js to automatically focus the first input[type=text] that is found the page content. What do you think?
Well, this would be also some approach which would prevent bigger codechanges.
Updated by Etienne Massip over 11 years ago
Jean-Philippe Lang wrote:
Another approach that would prevent autofocus attributes or js in each view would be add a few js lines in application.js to automatically focus the first input[type=text] that is found in the page content. What do you think?
Maybe autofocus on first input having a tabindex
value > 0 set and fallback to the first text input if none found?
FWIW, I like the use of HTML5 autofocus
attribute as Daniel suggested.
Updated by Jean-Philippe Lang over 10 years ago
- Tracker changed from Patch to Feature
- Subject changed from Autofocus version name in versions/_form.html.erb to Focus first text field automatically
- Status changed from New to Closed
- Assignee set to Jean-Philippe Lang
- Target version set to 2.5.0
- Resolution set to Fixed
Javascript added in r12670. It sets focus to the first text field unless a field has focus already.
Updated by b b about 9 years ago
Hi, this modification break the anchors on links like this one :
https://core.spip.net/projects/spip/repository/entry/spip/ecrire/inc/utils.php#L404
Since the first input text get the focus, the anchor in the link doesn't "works".
If we comment http://www.redmine.org/projects/redmine/repository/revisions/12670/diff/trunk/public/javascripts/application.js the anchor works well.
Updated by Toshi MARUYAMA about 9 years ago
b b wrote:
Hi, this modification break the anchors on links like this one :
https://core.spip.net/projects/spip/repository/entry/spip/ecrire/inc/utils.php#L404
Since the first input text get the focus, the anchor in the link doesn't "works".
If we comment http://www.redmine.org/projects/redmine/repository/revisions/12670/diff/trunk/public/javascripts/application.js the anchor works well.
I created issue #17757.
Updated by Toshi MARUYAMA about 9 years ago
- Related to Defect #17757: Link with hash does not work on Firefox added