#40301 closed enhancement (fixed)
New filter to disable auto-focus on the login screen
Reported by: | afercia | Owned by: | afercia |
---|---|---|---|
Milestone: | 4.8 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Login and Registration | Keywords: | has-screenshots has-patch |
Focuses: | ui, accessibility | Cc: |
Description
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.
Attachments (2)
Change History (13)
#2
@
8 years ago
- Keywords has-patch added
Yep I've seen that ticket :) To me, it sounds more related to a (very annoying) Chrome specific behaviour.
40301.diff adds a new filter which defaults to true. Using it would be as simple as:
add_filter( 'enable_login_autofocus', '__return_false' );
Also removes a space in a doc-block.
#3
@
8 years ago
@afercia
Patch applies cleanly and using the filter works as described and autofocus was not set in Chrome, when defined.
This ticket was mentioned in Slack in #accessibility by afercia. View the logs.
8 years ago
#5
@
8 years ago
- Milestone changed from Awaiting Review to 4.8
Discussed in today's accessibility meeting, moving to 4.8 as something to address maybe together with #30023.
This ticket was mentioned in Slack in #accessibility by afercia. View the logs.
7 years ago
This ticket was mentioned in Slack in #core by jeffpaul. View the logs.
7 years ago
#8
@
7 years ago
- Keywords needs-dev-note added
- Owner set to afercia
- Status changed from new to assigned
Adding the keyword needs-dev-note
for the new filter.
Sounds like a duplicate of #30023 to me. I'd love to fix it because the bug mentioned in that ticket is annoying.