Making WordPress.org

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#2391 closed enhancement (fixed)

Autofocus on login page

Reported by: szepeviktor's profile szepe.viktor Owned by: pento's profile pento
Milestone: Priority: normal
Component: Login & Authentication Keywords:
Cc:

Description

Would it be possible to add autofocus on the wp.org login page?
https://login.wordpress.org/

Thank you.

Change History (4)

#1 @SergeyBiryukov
8 years ago

  • Component changed from General to Login & Authentication
  • Keywords needs-patch added

In WordPress core, wp-login.php file has a wp_attempt_focus() function to handle this.

On https://login.wordpress.org/, the login.php template uses the wp_login_form() function, which doesn't have autofocus functionality. It falls back to regular login form though (which does have autofocus) in case of an error, e.g. if you enter an empty username or password.

A quick fix would be to copy wp_attempt_focus() to login.php template. It might also be a worthy enhancement for wp_login_form() function in core.

There's also an autofocus HTML attribute, but core only uses it in wp-admin/includes/theme-install.php, see [WP21143]. I guess the JS option is more flexible, because it focuses different fields (user_login vs. user_pass), depending on previous input.

#2 follow-up: @pento
8 years ago

  • Keywords needs-patch removed
  • Owner set to pento
  • Status changed from new to assigned

I'm not entirely sure why wp_attempt_focus() uses a setTimeout(), and I don't know if @azaozz would remember why he added it 8 years ago.

In the mean time, I'll reuse the relevant bits of wp_attempt_focus() - it redirects to wp-login.php, so we don't need to do all the username/password/error handling that the full version does.

#3 @pento
8 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 4699:

Login: Auto-focus on the username field on page load, code borrowed from wp-login.php.

Fixes #2391.

#4 in reply to: ↑ 2 @azaozz
8 years ago

Replying to pento:

I don't know if @azaozz would remember why he added it 8 years ago.

I wish I could :) Looks like some (old?) browsers needed a bit of time to autofill the user_login field before we try to select the text. Don't think it needs the try/catch any more, but doesn't hurt.

Note: See TracTickets for help on using tickets.