Fix autofilled inputs rendering white in dark mode - #51221
Conversation
The autofill rule covered the browser's own background with an inset shadow hardcoded to #fff, so autofilled fields stayed white regardless of theme. In dark mode that leaves a bright white box, and the text is already themed to a light color, so it becomes nearly unreadable. Use the themed surface token instead of #fff. The text color in this rule already used a token, so only the background was pinned. Also add the standard :autofill selector. Only the -webkit- prefixed one was present, so Firefox never matched the rule and fell back to its own white fill. Dropped the redundant -webkit-box-shadow since autoprefixer adds prefixes per browserslist, and set caret-color so the cursor stays visible against the themed background.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
WalkthroughAutofilled Merge Risk: ⚪ Minimal · up to The change makes autofilled controls use theme-aware background, text, and caret colors while covering Firefox. No actionable merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #51221 +/- ##
=======================================
Coverage 68.66% 68.67%
=======================================
Files 4000 4000
Lines 258167 258171 +4
Branches 13686 13687 +1
=======================================
+ Hits 177282 177291 +9
+ Misses 65137 65132 -5
Partials 15748 15748
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Related issue: Resolves #51050
Autofilled inputs render with a white background regardless of theme, so in dark mode they appear as bright white boxes. The text in those fields is already themed to a light color, which leaves it close to unreadable.
Root cause
The autofill rule in
frontend/styles/global/_global.scsscovered the browser's own background with an inset shadow hardcoded to#fff:Two separate problems:
-webkit-text-fill-coloralready used$core-fleet-black, a theme token that flips to a light color in dark mode. So the text was correct all along and only the background was pinned to white — which is why the field reads as a white box with barely-visible text rather than simply being the wrong color.-webkit-prefixed selector was present, so Firefox never matched this rule and applied its own white fill.Changes
#fff→$core-fleet-white, the token that already pairs with$core-fleet-blackhere.:autofillselector alongside:-webkit-autofill.caret-colorso the text cursor stays visible against the themed background.-webkit-box-shadow— autoprefixer emits prefixes from the project's browserslist, and I confirmed the compiled output is identical with and without it.No new variables. Both colors are existing tokens that already flip:
--core-fleet-white--core-fleet-black:root(light)#ffffff#192147body.dark-mode#1a1c21#e2e4eaTesting
Verified manually in Firefox against a local dev server, which is the browser and scenario the issue reports:
/loginin dark mode.Before this change the autofilled fields render as white rectangles. With the change they take the dark surface color and sit flush with the login card, with the light text legible.
I also checked the compiled stylesheet rather than relying on the source alone. The rule builds to:
with a
-webkit--only fallback rule emitted alongside it, so browsers that don't understand:autofilldon't discard the whole selector list.body.dark-moderedefines both custom properties in the same output, so under dark mode the rule resolves to a#1a1c21surface with#e2e4eatext.How to verify
Ctrl+K→ "dark")./login. The theme is stored inlocalStorage, so it persists while signed out.:-webkit-autofillpath changed from a literal#fffto a token that resolves to#ffffff.Checklist for submitter
changes/,orbit/changes/oree/fleetd-chrome/changes.See Changes files for more information.
Testing
Not added — this is a stylesheet change and the frontend test suite doesn't assert on compiled CSS. Covered by the manual check and the build-output inspection above.
Summary by CodeRabbit