Edgewall Software

Opened 11 years ago

Last modified 10 years ago

#11084 closed enhancement

Edit pages should put focus on text input element — at Initial Version

Reported by: Ryan J Ollos <ryan.j.ollos@…> Owned by:
Priority: low Milestone: 1.0.2
Component: general Version: 1.0-stable
Severity: minor Keywords: jquery focus css
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

Several pages put the focus in "the right place" on page load, allowing someone to immediately start entering text without a lot of tabbing or using the mouse. The following pages do that well:

  • New Ticket: Summary text input gets focus.
  • Milestone edit: Name text input gets focus.
  • Search: Search text input gets focus.

Here's is a check of the places that jQuery's focus is used, not including JavaScript files such as query.js:

(t11081)user@debian-wheezy:~/Workspace/t11081$ grep -R --exclude-dir=.svn --exclude-dir=js ".focus()" trac-1.0-stable
trac-1.0-stable/trac/ticket/templates/milestone_edit.html:        $("#name").get(0).focus()
trac-1.0-stable/trac/ticket/templates/ticket.html:        $("#field-summary").focus();
trac-1.0-stable/trac/search/templates/search.html:      jQuery(document).ready(function($) {$("#q").get(0).focus()});

Here are some other places I'd like to see a text input or textarea have focus on page load:

  • Wiki edit: Wiki textarea
  • Admin Component/Milestone/Enum/Version/Repository edit: Name text input
  • Report edit: Title text input

The above cases feel like obvious candidates for this change. We could implement it more widely, for instance when navigating to the Admin General page, the Project Name input text field could be given focus. I don't like that as much since Admin General is not an edit page, rather a combination edit/view page. It seems like that change make unintended edits more likely. For example, a key slip and Project Name gets changed without the user noticing, and then they proceed to make their desired change, saving both (though a more verbose info message as shown in comment:8:ticket:11076 could help).

The ticket comment box seems like the most reasonable place to put the focus on the Ticket page, however for a typical ticket it won't be in the visible area on page load, so I've not set any element to have focus when the ticket page load.

Patch against 1.0-stable is forthcoming.

Change History (0)

Note: See TracTickets for help on using tickets.