Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Slider][material-ui] Convert to support CSS extraction #41201

Merged
merged 16 commits into from Mar 13, 2024

Conversation

mnajdova
Copy link
Member

@mnajdova mnajdova commented Feb 20, 2024

@mnajdova mnajdova added component: slider This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material labels Feb 20, 2024
@mnajdova mnajdova force-pushed the slider/convert-to-zero-runtime branch from ed00a4e to a28f3f0 Compare February 20, 2024 14:34
@mui-bot
Copy link

mui-bot commented Feb 20, 2024

Netlify deploy preview

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

@material-ui/core: parsed: +0.19% , gzip: +0.14%

Bundle size report

Details of bundle changes (Toolpad)
Details of bundle changes

Generated by 🚫 dangerJS against 739f777

@mnajdova mnajdova added the on hold There is a blocker, we need to wait label Feb 21, 2024
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Mar 1, 2024
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Mar 8, 2024
export const rootShouldForwardProp = (prop) => shouldForwardProp(prop) && prop !== 'classes';

export const slotShouldForwardProp = shouldForwardProp;
export { default as slotShouldForwardProp } from './slotShouldForwardProp';
Copy link
Member Author

@mnajdova mnajdova Mar 8, 2024

Choose a reason for hiding this comment

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

I had to extract these to separate files, otherwise we were ending up with importing from the styled.js, which resulted with the error:

/Users/marijanajdova/workspace/mui/apps/node_modules/.pnpm/@wyw-in-js+transform@0.5.0_typescript@5.3.3/node_modules/@wyw-in-js/transform/lib/module.js:223
      throw new EvalError(`${e.message} in${this.callstack.join('\n| ')}\n`);
      ^

EvalError: _systemDefaultTheme is not defined in/Users/marijanajdova/workspace/mui/packages/mui-system/build/createStyled.js
| /Users/marijanajdova/workspace/mui/packages/mui-material/build/styles/slotShouldForwardProp.js
| /Users/marijanajdova/workspace/mui/packages/mui-material/build/Slider/Slider.js

Once the PR is merged, I will update all imports we have in Material UI, so that we don't have to add additional check in the migration steps.

cc @brijeshb42, @siriwatknp

Copy link
Member

Choose a reason for hiding this comment

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

@mnajdova mnajdova marked this pull request as ready for review March 8, 2024 11:57
@mnajdova mnajdova removed the on hold There is a blocker, we need to wait label Mar 8, 2024
Copy link
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.

👍

@mnajdova mnajdova merged commit 144dd13 into mui:master Mar 13, 2024
19 checks passed
@mnajdova mnajdova changed the title [Slider][material-ui] Make it zero-runtime compatible [Slider][material-ui] Convert to support CSS extractions Mar 13, 2024
@mnajdova mnajdova changed the title [Slider][material-ui] Convert to support CSS extractions [Slider][material-ui] Convert to support CSS extraction Mar 13, 2024
@oliviertassinari
Copy link
Member

oliviertassinari commented Mar 22, 2024

This change introduced a regression somehow, it could be a breaking change too.

Before: https://deploy-preview-41198--material-ui.netlify.app/material-ui/

SCR-20240323-btws

After: https://deploy-preview-41201--material-ui.netlify.app/material-ui/

SCR-20240323-buee

Can we prioritize this regression in master? Thanks

@oliviertassinari oliviertassinari added the package: pigment-css Specific to @pigment-css/* label Mar 22, 2024
@siriwatknp
Copy link
Member

This change introduced a regression somehow, it could be a breaking change too.

It is strange that changing the order of the styles in the variant fixes the issue

diff --git a/packages/mui-material/src/Slider/Slider.js b/packages/mui-material/src/Slider/Slider.js
index 5b5ed8c9e9..f87f34f51b 100644
--- a/packages/mui-material/src/Slider/Slider.js
+++ b/packages/mui-material/src/Slider/Slider.js
@@ -277,6 +277,30 @@ export const SliderThumb = styled('span', {
     },
   },
   variants: [
+    {
+      props: { size: 'small' },
+      style: {
+        width: 12,
+        height: 12,
+        '&::before': {
+          boxShadow: 'none',
+        },
+      },
+    },
+    {
+      props: { orientation: 'horizontal' },
+      style: {
+        top: '50%',
+        transform: 'translate(-50%, -50%)',
+      },
+    },
+    {
+      props: { orientation: 'vertical' },
+      style: {
+        left: '50%',
+        transform: 'translate(-50%, 50%)',
+      },
+    },
     ...Object.keys((theme.vars ?? theme).palette)
       .filter((key) => (theme.vars ?? theme).palette[key].main)
       .map((color) => ({
@@ -305,30 +329,6 @@ export const SliderThumb = styled('span', {
           },
         },
       })),
-    {
-      props: { size: 'small' },
-      style: {
-        width: 12,
-        height: 12,
-        '&::before': {
-          boxShadow: 'none',
-        },
-      },
-    },
-    {
-      props: { orientation: 'horizontal' },
-      style: {
-        top: '50%',
-        transform: 'translate(-50%, -50%)',
-      },
-    },
-    {
-      props: { orientation: 'vertical' },
-      style: {
-        left: '50%',
-        transform: 'translate(-50%, 50%)',
-      },
-    },
   ],
 }));

I checked the calculated styles before passing to emotion, it looks normal. There is no problem with /material-ui/react-slider/, the styles are the same.

Anyway, I don't have much time to dig deep to the root cause but I will try to find some time. It looks like an issue related to our doc.

@vimutti77
Copy link
Contributor

This PR may be the cause of this #41753 ?

@ZeeshanTamboli
Copy link
Member

This PR may be the cause of this #41753 ?

@vimutti77 Yes, looks related.

Comment on lines +62 to +69
...Object.keys((theme.vars ?? theme).palette)
.filter((key) => (theme.vars ?? theme).palette[key].main)
.map((color) => ({
props: { color },
style: {
color: (theme.vars || theme).palette[color].main,
},
})),
Copy link
Member

Choose a reason for hiding this comment

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

Another regression occurred since Material UI v5.15.14 - #41772. This evaluation fails for nested theme palette fields, when the color here becomes an object rather than a string.


Side note: We could consider using reduce() here to avoid two separate loops.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: slider This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material package: pigment-css Specific to @pigment-css/*
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants