From 4f727e28bed66f9c90ae305c99121c1d5de04860 Mon Sep 17 00:00:00 2001 From: Lazizbek Ergashev Date: Tue, 1 Dec 2026 08:57:19 +0200 Subject: [PATCH] Fix translucent TableCell border with nativeColor (#49638) (cherry picked from commit 1bcf7e0c3b5cdfe9ea90cfa75b821b78992a252b) Co-authored-by: Zeeshan Tamboli Co-Authored-By: Claude Opus 5.5 --- .../mui-material/src/styles/createTheme.test.js | 13 +++++++++++++ .../mui-material/src/styles/createThemeWithVars.js | 8 ++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/packages/mui-material/src/styles/createTheme.test.js b/packages/mui-material/src/styles/createTheme.test.js index 45ddfba73b8926..9b299ad0352ebc 100644 --- a/packages/mui-material/src/styles/createTheme.test.js +++ b/packages/mui-material/src/styles/createTheme.test.js @@ -799,6 +799,19 @@ describe('createTheme', () => { }), ).not.toWarnDev(); }); + + it('should make the TableCell border opaque with nativeColor', () => { + const theme = createTheme({ + cssVariables: { nativeColor: true }, + colorSchemes: { light: true, dark: true }, + }); + expect(theme.colorSchemes.light.palette.TableCell.border).to.equal( + 'color-mix(in oklch, oklch(from var(--mui-palette-divider) l c h / 1), #fff 88%)', + ); + expect(theme.colorSchemes.dark.palette.TableCell.border).to.equal( + 'color-mix(in oklch, oklch(from var(--mui-palette-divider) l c h / 1), #000 68%)', + ); + }); }); // Skip WebKit and firefox because they have a slightly different value diff --git a/packages/mui-material/src/styles/createThemeWithVars.js b/packages/mui-material/src/styles/createThemeWithVars.js index a8673f43e44b21..2a9277585b405b 100644 --- a/packages/mui-material/src/styles/createThemeWithVars.js +++ b/packages/mui-material/src/styles/createThemeWithVars.js @@ -570,7 +570,9 @@ export default function createThemeWithVars(options = {}, ...args) { 'border', colorMix( safeLighten, - safeAlpha(nativeColor ? getCssVar('palette-divider') : palette.divider, 1), + nativeColor + ? `oklch(from ${getCssVar('palette-divider')} l c h / 1)` + : safeAlpha(palette.divider, 1), 0.88, ), ); @@ -887,7 +889,9 @@ export default function createThemeWithVars(options = {}, ...args) { 'border', colorMix( safeDarken, - safeAlpha(nativeColor ? getCssVar('palette-divider') : palette.divider, 1), + nativeColor + ? `oklch(from ${getCssVar('palette-divider')} l c h / 1)` + : safeAlpha(palette.divider, 1), 0.68, ), );