Project

General

Profile

Actions

Feature #13134

closed

Focus first text field automatically

Added by Harry Garrood about 11 years ago. Updated almost 9 years ago.

Status:
Closed
Priority:
Normal
Category:
UI
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed

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

Related to Redmine - Defect #17757: Link with hash does not work on FirefoxClosedJean-Philippe Lang

Actions
Actions #1

Updated by Daniel Felix about 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" />

Actions #2

Updated by Harry Garrood about 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)
Actions #3

Updated by Daniel Felix about 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. :-)

Actions #4

Updated by Jean-Philippe Lang about 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?

Actions #5

Updated by Daniel Felix about 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.

Actions #6

Updated by Etienne Massip about 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.

Actions #7

Updated by Jean-Philippe Lang about 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.

Actions #8

Updated by b b almost 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.

Actions #9

Updated by Toshi MARUYAMA almost 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.

Actions #10

Updated by Toshi MARUYAMA almost 9 years ago

  • Related to Defect #17757: Link with hash does not work on Firefox added
Actions

Also available in: Atom PDF