New filter to disable auto-focus on the login screen
|Reported by:||afercia||Owned by:|
|Component:||Login and Registration||Keywords:||has-screenshots has-patch|
On the login screen, wp_attempt_focus() tries to auto-focus the login input fields:
By doing so, anything that comes before the input fields (e.g. the logo) will be "skipped" for keyboard users and screen reader users. While this may make sense when the login screen is the default one, it can be confusing when the login screen is customised.
Using filters and actions, plugin authors can heavily customise the login screen, adding any kind of content before the login default fields (including additional form fields). In this case, skipping all that content wouldn't be so ideal.
There are hacky ways to avoid the call to wp_attempt_focus(), like setting again the global $error and as far as I see, people are already doing that (just googled a bit and found some use cases). I'd propose to just add a more standard way to don't print out the call to wp_attempt_focus().
Worth noting the auto-focus will still work on other wp-login.php views like, for example, the lost password one. It probably makes sense to still have auto-focus where the users task is so specific.
It will also still work when there are error messages, because it is called by wp_shake_js(). For example, when entering a wrong password, I'd say it still makes sense to focus the password field.
In these two cases, I'd avoid any change. The filter should work just on the initial login screen.