Skip to content

[material-ui][Link] Fix crash when the underline color is not parsable - #49054

Open
lazerg wants to merge 1 commit into
mui:masterfrom
lazerg:fix/issue-49052-link-underline-color
Open

[material-ui][Link] Fix crash when the underline color is not parsable#49054
lazerg wants to merge 1 commit into
mui:masterfrom
lazerg:fix/issue-49052-link-underline-color

Conversation

@lazerg

@lazerg lazerg commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

closes #49052

getTextDecoration runs alpha() on the resolved color, so underline="always" together with a CSS color keyword like color="white" throws MUI: Unsupported \white` colorduring render and can take the whole app down with it. It now usesprivate_safeAlpha, the helper createThemeWithVars` already relies on for the same reason, so a color the parser cannot decompose falls back to itself instead of throwing.

Only the crash is covered here, the customization and opt-out points raised in the issue are separate.

@code-infra-dashboard

Copy link
Copy Markdown

Deploy preview

https://deploy-preview-49054--material-ui.netlify.app/
QR code for https://deploy-preview-49054--material-ui.netlify.app/

Bundle size

Bundle Parsed size Gzip size
@mui/material ▼-15B(0.00%) 🔺+3B(0.00%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/private-theming 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


Check out the code infra dashboard for more information about this PR.

@zannager zannager added the scope: link Changes related to the link. label Aug 31, 2026
@silviuaavram
silviuaavram requested review from silviuaavram and a lite review from Copilot September 1, 2026 06:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 render-time crash in Link when underline="always" is used with a valid CSS named color (e.g. "white") that MUI’s color parser cannot decompose, by switching the underline color computation to a non-throwing alpha helper.

Changes:

  • Replace alpha() with private_safeAlpha() in getTextDecoration so unsupported colors fall back to the original string instead of throwing.
  • Add a regression test ensuring Link with color="white" and underline="always" does not crash.
  • Update getTextDecoration unit tests to reflect the new non-throwing behavior for named colors.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
packages/mui-material/src/Link/Link.test.js Adds regression coverage for underline="always" with a named CSS color.
packages/mui-material/src/Link/getTextDecoration.ts Switches underline alpha computation to private_safeAlpha to prevent render crashes.
packages/mui-material/src/Link/getTextDecoration.test.js Updates expectations so named colors no longer throw and instead return the original color.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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

Labels

scope: link Changes related to the link.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Valid CSS color strings can throw during render when Link has underline="always", crashes the app

3 participants