プロジェクト

全般

プロフィール

Vote #73336

完了

Focus first text field automatically

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
UI_10
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
10
version_id:
75
issue_org_id:
13134
author_id:
44912
assigned_to_id:
1
comments:
10
status_id:
5
tracker_id:
2
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

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.


journals

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" />
--------------------------------------------------------------------------------
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@)
--------------------------------------------------------------------------------
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. :-)
--------------------------------------------------------------------------------
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?
--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------
Javascript added in r12670. It sets focus to the first text field unless a field has focus already.
--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------


related_issues

relates,Closed,17757,Link with hash does not work on Firefox

Admin Redmine さんが約4年前に更新

  • カテゴリUI_10 にセット
  • 対象バージョン2.5.0_75 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0