Skip to content

[input] Fix high contrast cutoff on first character#48150

Merged
silviuaavram merged 6 commits intomui:masterfrom
silviuaavram:fix/high-contrast-textfield
Mar 31, 2026
Merged

[input] Fix high contrast cutoff on first character#48150
silviuaavram merged 6 commits intomui:masterfrom
silviuaavram:fix/high-contrast-textfield

Conversation

@silviuaavram
Copy link
Copy Markdown
Member

@silviuaavram silviuaavram commented Mar 30, 2026

The non-breaking space character, used to create the ::before pseudo-element at InputRoot, receives color when High Contrast is used, which in turn obstructs part of the first character of the Input's placeholder/value. Using empty content fixes the issue and keeps the same previous behavior.

Add also a visual test with high contrast emulation to check it won't regress.

Fixes #47967

Before After
Screenshot 2026-03-30 at 15 54 03 Screenshot 2026-03-30 at 15 53 55

@silviuaavram silviuaavram added type: bug It doesn't behave as expected. accessibility a11y v7.x needs cherry-pick The PR should be cherry-picked to master after merge. scope: input Changes related to the input. labels Mar 30, 2026
@mui-bot
Copy link
Copy Markdown

mui-bot commented Mar 30, 2026

Netlify deploy preview

https://deploy-preview-48150--material-ui.netlify.app/

Bundle size report

Bundle Parsed size Gzip size
@mui/material ▼-12B(0.00%) ▼-9B(-0.01%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes

Generated by 🚫 dangerJS against 9580cf3

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a High Contrast rendering issue in the Material UI Input underline where the ::before pseudo-element’s non‑breaking space could receive forced colors and visually cut off the first character of the placeholder/value.

Changes:

  • Replace &::before pseudo-element content from a non‑breaking space ("\00a0") to an empty string ("") in InputRoot to avoid forced-color artifacts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mj12albert
Copy link
Copy Markdown
Member

I think FilledInput also has this issue:

Comment on lines +166 to +171
const testcase = await renderFixture('/regression-TextField/StandardTextField');
await takeScreenshot({
testcase,
route: '/regression-TextField/StandardTextFieldForcedColors',
});
await page.emulateMedia({ forcedColors: 'none' });
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const testcase = await renderFixture('/regression-TextField/StandardTextField');
await takeScreenshot({
testcase,
route: '/regression-TextField/StandardTextFieldForcedColors',
});
await page.emulateMedia({ forcedColors: 'none' });
try {
const testcase = await renderFixture('/regression-TextField/StandardTextField');
await takeScreenshot({
testcase,
route: '/regression-TextField/StandardTextFieldForcedColors',
});
} finally {
await page.emulateMedia({ forcedColors: 'none' });
}

Claude Code suggestion: try/finally so that if takeScreenshot (or renderFixture) throws, the cleanup will still run, avoids subsequent tests being stuck with forced colors

Copy link
Copy Markdown
Member

@siriwatknp siriwatknp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking a look on this 👍

@silviuaavram
Copy link
Copy Markdown
Member Author

Confirmation that the visual test on high contrast, without any fix, shows the issue

image

@silviuaavram silviuaavram merged commit 50c6bec into mui:master Mar 31, 2026
19 checks passed
@silviuaavram silviuaavram deleted the fix/high-contrast-textfield branch March 31, 2026 10:15
@github-actions
Copy link
Copy Markdown

Cherry-pick PRs will be created targeting branches: v7.x

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

Labels

accessibility a11y needs cherry-pick The PR should be cherry-picked to master after merge. scope: input Changes related to the input. type: bug It doesn't behave as expected. v7.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Textfield Variant Standard cuts off text on High Contrast/Accessibility mode

5 participants