Opened 9 years ago

Closed 8 years ago

#3797 closed enhancement (fixed)

Put autofocus on Search input field

Reported by: guerda Owned by: rails-dev@…
Priority: minor Milestone: Wishlist
Component: website Version:
Keywords: Cc: guerda


If you visit, there's no input field that accepts key strokes immediately. There's no input field at all that may need user inputs, but the search field. I propose to put the autofocus on the search input field so that a user can directly search for a place, a street or whatever.

The following snippet (inspired by [1]) would establish autofocussing the search input field via the HTML5 autofocus attribute and a fallback method for not so current browsers.

    <form action="/" id="search_form" method="get" onsubmit="...">
      <input id="query" name="query" tabindex="1" value="" type="text" autofocus="autofocus">
      <input name="commit" value="Los" type="submit">

    <script type="text/javascript">
    if (!("autofocus" in document.createElement("input"))) {


Attachments (1)

0001-ref-3797.patch (1.4 KB) - added by guerda 9 years ago.
Patch file for this feature (applyable on git c4f7a8346a7)

Download all attachments as: .zip

Change History (6)

Changed 9 years ago by guerda

Attachment: 0001-ref-3797.patch added

Patch file for this feature (applyable on git c4f7a8346a7)

comment:1 Changed 9 years ago by Tom Hughes

Owner: changed from Tom Hughes to rails-dev@…

comment:2 Changed 8 years ago by guerda

Hi rails-dev team!

Is there an option to include this feature?

Kind regards, guerda

comment:3 Changed 8 years ago by Tom Hughes

Couple of comments:

  • It would be better to use jQuery rather than non-portable document methods
  • There seems to be little benefit to using the HTML5 autofocus attribute - if we need the fallback code for other cases then we might as well just use it all the time

At the end of the day, it will happen a lot quicker if you provide a patch for the source, otherwise you'll have to wait until somebody is interested enough to write one.

comment:5 Changed 8 years ago by Tom Hughes

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.