Skip to content

#30023 Chrome autofill password keeps showing in password field - #13231

Draft
skikken wants to merge 1 commit into
WordPress:trunkfrom
skikken:fix/30023-wp-attempt-focus-clears-password
Draft

#30023 Chrome autofill password keeps showing in password field#13231
skikken wants to merge 1 commit into
WordPress:trunkfrom
skikken:fix/30023-wp-attempt-focus-clears-password

Conversation

@skikken

@skikken skikken commented Aug 22, 2026

Copy link
Copy Markdown

On the login screen, wp_attempt_focus() clears form fields after a failed login attempt. In Chrome this backfires: after a failed login, the browser autofills the password field, wp_attempt_focus() empties it via JavaScript, but Chrome keeps displaying the field as filled with dots even though it is actually empty. Submitting then fails with "ERROR: The password field is empty."

This removes the field-clearing behavior from wp_attempt_focus(). After a failed attempt, the function now only focuses and selects the relevant field:

  • When the username was preserved ($user_login set), it focuses user_pass.
  • Otherwise it focuses user_login.

Trac ticket: https://core.trac.wordpress.org/ticket/30023

Use of AI Tools


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

Chrome autofills the password field after a failed login and keeps
displaying it as filled even after the field is emptied via JS,
causing an empty password error on submit.

Focus and select the field instead of clearing it. Selecting the
stale value preserves the overwrite-on-type behavior without
fighting browser autofill.

Closes #30023
@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant