[material-ui][Link] Fix crash when the underline color is not parsable - #49054
Open
lazerg wants to merge 1 commit into
Open
[material-ui][Link] Fix crash when the underline color is not parsable#49054lazerg wants to merge 1 commit into
lazerg wants to merge 1 commit into
Conversation
Deploy previewBundle size
Check out the code infra dashboard for more information about this PR. |
silviuaavram
requested review from
silviuaavram
and
a lite review from Copilot
September 1, 2026 06:51
Contributor
There was a problem hiding this comment.
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()withprivate_safeAlpha()ingetTextDecorationso unsupported colors fall back to the original string instead of throwing. - Add a regression test ensuring
Linkwithcolor="white"andunderline="always"does not crash. - Update
getTextDecorationunit 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #49052
getTextDecorationrunsalpha()on the resolved color, sounderline="always"together with a CSS color keyword likecolor="white"throwsMUI: Unsupported \white` colorduring render and can take the whole app down with it. It now usesprivate_safeAlpha, the helpercreateThemeWithVars` 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.