Skip to content

fix: var()-safe lighten() for FungibleTokenInput hover - #12437

Merged
guanbinrui merged 1 commit into
developfrom
fix/mui-lighten-css-var
Sep 5, 2026
Merged

fix: var()-safe lighten() for FungibleTokenInput hover#12437
guanbinrui merged 1 commit into
developfrom
fix/mui-lighten-css-var

Conversation

@swkatmask

Copy link
Copy Markdown
Contributor

Problem

FungibleTokenInput crashed on render:

Error: MUI: Unsupported `var(--mui-palette-maskColor-primary)` color.
    at decomposeColor → lighten → useStyles → FungibleTokenInputUI

Root cause

Introduced by the MUI v9 upgrade (#52d5bce737), which enabled
cssVariables: { colorSchemeSelector: 'data' } and switched
theme.palette.*theme.vars.palette.*. The latter is now the literal
string var(--mui-palette-maskColor-primary), and MUI's lighten() only
parses #nnn / rgb() / hsl() / color(), so it throws. The call sits
inside useStyles(), so the component crashed on mount. This was the last
lighten/darken usage left on theme.vars.

Change

  • Add a color-mix-based lighten() to @masknet/theme next to the
    existing var()-safe alpha() (color-mix(in srgb, ${color}, white ${coefficient * 100}%))
    — channel-wise identical to MUI's lighten for rgb colors, so the hover
    color is unchanged visually.
  • Import lighten from @masknet/theme in FungibleTokenInput instead of
    @mui/material (call site unchanged).

Verification

  • pnpm lint clean
  • Runtime (dev build, x.com): the Lucky Drop (Red Packet) dialog mounts
    FungibleTokenInput without the MUI error; the injected
    .selectToken:hover rule resolves in Chrome to exactly
    lighten(#1C68F3, 0.1) = rgb(51, 119, 244), matching the pre-upgrade color

MUI lighten() only parses literal colors and throws on
var(--mui-palette-maskColor-primary) from the cssVariables theme
(#52d5bce737). Add a color-mix based lighten() to @masknet/theme
alongside alpha() and use it instead.
@swkatmask
swkatmask force-pushed the fix/mui-lighten-css-var branch from 098b40a to 3eb13e2 Compare September 5, 2026 15:49
@guanbinrui
guanbinrui merged commit f5be376 into develop Sep 5, 2026
14 of 15 checks passed
@guanbinrui
guanbinrui deleted the fix/mui-lighten-css-var branch September 5, 2026 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants