Opened 2 months ago
Last modified 2 weeks ago
#66130 new defect (bug)
Login language switcher button has no explicit background, unreadable with custom login background
| Reported by: | enrico.sorcinelli | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Login and Registration | Version: | 7.0 |
| Severity: | normal | Keywords: | close 2nd-opinion |
| Cc: | Focuses: | accessibility, css |
Description
Hi everyone,
I noticed a small contrast issue on the login screen and wanted to report it, along with a proposed fix: happy to hear if I'm missing something or if this has already been discussed elsewhere. I searched Trac before opening this, but didn't find an existing one report, so apologies in advance if this turns out to be a duplicate.
Description: when more than one language is installed, WordPress shows a language switcher button on wp-login.php. Looking at login.css, the rule for this button (.login .language-switcher .button) only sets margin-bottom and it doesn't declare its own background, so it relies implicitly on whatever background happens to sit behind it.
This works fine with the default light login background, but if the login screen is customized (via a custom stylesheet enqueued, a white-labeling plugin, or similar) with a dark background or one close to the button's own text color, the button's text becomes very hard to read, since nothing guarantees contrast between the two.
How to reproduce: with WordPress Playground use the following blueprint:
{
"landingPage": "/wp-login.php",
"preferredVersions": { "php": "8.0", "wp": "latest" },
"steps": [
{
"step": "setSiteLanguage",
"language": "it_IT"
},
{
"step": "writeFile",
"path": "/wordpress/wp-content/mu-plugins/repro-login-bg.php",
"data": "<?php add_action('login_enqueue_scripts', function() { echo '<style>body.login{background:#3c3c3c;}</style>'; });"
}
],
"login": false
}
Expected: the button should have an explicit background so it stays readable regardless of the page's background.
Actual: the button's background is implicit/transparent and blends into custom login backgrounds.
I've attached simple a patch that adds an explicit background-color to the button rule, reusing a value already used for backgrounds elsewhere in wp-admin.
Would appreciate a second look on whether that's the right value to reuse, or if there's a more appropriate approach for this (e.g. using a dedicated class and so on).
Thanks for taking a look!
Attachments (2)
Change History (9)
This ticket was mentioned in PR #13611 on WordPress/wordpress-develop by @arkaprabhachowdhury.
2 months ago
#1
This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.
8 weeks ago
@afercia commented on PR #13611:
8 weeks ago
#4
Closing because the related ticket already had a patch submitted earlier than this PR and this PR just duplicates the exact same proposed fix of the patch.
#5
@
8 weeks ago
For clarification: this ticket already had a patch attached. I just closed the PR that was submitted after the first patch given also that the PR just duplicated the same proposed fix.
#6
@
8 weeks ago
Test Report
Description
This report validates whether ticket:66130:66130.patch resolves the button contrast issue on the login screen's language switcher when a custom dark background is applied.
Patch tested: ticket:66130:66130.patch
Environment
- WordPress: 7.2-alpha-63166-src (trunk)
- Browser: Chrome (macOS)
- Server: Nginx / PHP 8.4 (Local Stratos)
Steps to Reproduce
- Navigate to
wp-login.phpwith multiple languages enabled so the language switcher appears below the form. - Apply a dark background (e.g.
body.login { background: #3c3c3c; }simulating a custom login theme or plugin). - Inspect the language switcher button (
.login .language-switcher .button).
Expected Results
The button should declare an explicit background so that text remains legible regardless of the underlying page background.
Actual Results
- ❌ Before Patch: The button background is transparent/implicit. On
#3c3c3c, the dark button text (#2c3338) has inadequate contrast (~1.2:1), making it hard to read and failing WCAG accessibility guidelines. - ✅ After Patch: The button explicitly receives
background-color: #f6f7f7. Contrast against the button surface is sharp (~11.5:1, passing WCAG AAA), providing clear readability independently of the page background. - ✅ On the default light background (
#f0f0f1), the button renders consistently with standard WordPress secondary button styling.
#7
@
2 weeks ago
- Keywords close 2nd-opinion added; has-patch removed
- Version trunk → 7.0
The button's transparent background requires additional custom CSS now when the background is dark. Hopefully any custom CSS has been updated in the last five months.
Adding a new requirement is not friendly, but the .language-switcher label already needed a light text color against a dark background. The links and logo needed adjustments too. Any patch should be tested with more elaborate custom styles, including my login styles gist and more variations.
If this ticket moves forward:
- The
.login .language-switcher .buttonselector specificity is too high because it could override custom CSS in use today with selectors such as.wp-core-ui .buttonand.wp-core-ui .button-secondary. Three classes would also override the default:hoverstate. - To follow the transparent styling, the default background color would need to match the body color of
#f0f0f1, not the#f6f7f7background from earlier releases. - The
:hoverstate is mostly transparent but adds 4% of the theme color withrgba(var(--wp-admin-theme-color--rgb, 56, 88, 233), 0.04), which looks like#e8e9f0with the login background.
.language-switcher .button,
.language-switcher .button:focus {
background-color: #f0f0f1;
}
.language-switcher .button:hover {
background-color: #e8e9f0;
}
The login language switcher uses the default secondary button style, which now has a transparent background. On customized login screens with dark backgrounds, this can leave the button text and border without sufficient visual separation.
This adds the standard light admin background color specifically to the language switcher button so it remains readable independently of the login page background.
Testing
wp-login.php.#3c3c3c.#f6f7f7background and remains readable.Browser verification confirmed the button background changes from transparent before the patch to
rgb(246, 247, 247)after the patch, while retaining the existing text and border colors.Checks run:
grunt precommit:cssphp vendor/bin/phpcbf src/wp-login.phpphp vendor/bin/phpcs src/wp-login.phpgit diff --checkUse of AI Tools
AI assistance: Yes
Tool(s): Codex
Model(s): GPT-5
Used for: Ticket analysis, implementation, browser verification, test execution, and drafting this pull request description.