-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[data grid] should work with theme scoping (e.g. theme-ui) #10484
Comments
Hey @jln-dk, thank you for using MUI X DataGrid and reporting the issue related to theme scoping. It's the second time in a while we've seen an issue related to the theme scoping, here's the previous one #10430 (already fixed) Here's how to fix it: diff --git a/packages/grid/x-data-grid/src/components/GridSelectedRowCount.tsx b/packages/grid/x-data-grid/src/components/GridSelectedRowCount.tsx
index c389b75a0..81f463f34 100644
--- a/packages/grid/x-data-grid/src/components/GridSelectedRowCount.tsx
+++ b/packages/grid/x-data-grid/src/components/GridSelectedRowCount.tsx
@@ -2,7 +2,7 @@ import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import { unstable_composeClasses as composeClasses } from '@mui/utils';
-import { styled, SxProps, Theme } from '@mui/system';
+import { styled, SxProps, Theme } from '@mui/material/styles';
import { useGridApiContext } from '../hooks/utils/useGridApiContext';
import { getDataGridUtilityClass } from '../constants/gridClasses';
import { useGridRootProps } from '../hooks/utils/useGridRootProps'; Feel free to open up a PR with a fix if you want to see this specific item fixed faster. For the long term fix: @siriwatknp please let us know if you have some knowledge about any such plans. |
This would basically undo #8032 |
It appears that the issue lies with the use of a |
I wonder how does it work with the variant from |
Most of the components use |
If I am getting it right, I think that a proper solution to this problem will be one of the following:
|
Let me clarify how the theme scoping works at the moment and we can discuss the way to go for MUI X components. @mui/system provides a factory function @mui/material and @mui/joy use The root cause of the error is the I think DataGrid should create it's own Here is what it looks like: // styles/styled.ts
+ import { createStyled } from '@mui/system';
+ // hardcode theme id to avoid importing from @mui/material
+ const styled = createStyled({ themeId: '$$material' });
+ export default styled;
diff --git a/packages/grid/x-data-grid/src/components/GridSelectedRowCount.tsx b/packages/grid/x-data-grid/src/components/GridSelectedRowCount.tsx
index c389b75a0..a0218a542 100644
--- a/packages/grid/x-data-grid/src/components/GridSelectedRowCount.tsx
+++ b/packages/grid/x-data-grid/src/components/GridSelectedRowCount.tsx
@@ -2,7 +2,8 @@ import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import { unstable_composeClasses as composeClasses } from '@mui/utils';
-import { styled, SxProps, Theme } from '@mui/system';
+import { SxProps, Theme } from '@mui/system';
+import styled from '../styles/styled';
import { useGridApiContext } from '../hooks/utils/useGridApiContext';
import { getDataGridUtilityClass } from '../constants/gridClasses';
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
|
@siriwatknp's This makes sense in the immediate 👍. About the long term:
|
Hi, is there a workaround for this as an MUI consumer while we wait for a fix to be released? |
Hi @oliviertassinari 👋 Do you know if there has been any movement on this? The issue here is blocking us from integrating some components we've made using another library. |
I added a comment here. You can follow the PR. |
Are there any updates coming from this? I see that #10498 hasn't had any commits in 7 months and the last comment was 3 months ago. Has this stalled out? In the meantime, are there any workarounds that consumers can apply? |
I'm also seeing #12432 is open in a draft state and guessing that this relates to this comment. If this is the route, is there an ETA? This is a blocking issue for adopting DataGrid which we would like to do. |
No updates, we plan to remove material-ui bundling but we don't have an ETA and I don't understand the implications for theme scoping which I haven't worked with yet. Maybe @cherniavskii or @MBilalShafi can provide more details on which workarounds could be used. |
Steps to reproduce
Link to live example: https://codesandbox.io/s/youthful-chaplygin-lw7d8y?file=/src/demo.tsx
Steps:
@mui/material
and@mui/x-data-grid
.<DataGrid>
and click on e.g. a checkbox in the data grid.Current behavior
If you click on e.g. a checkbox in the data grid, the app will break.
Expected behavior
It should work and use the provided theme, just as other components in
@mui/material
.Context
With MUI it's possible to do theme scoping to avoid issues when using multiple styling solutions in one app, e.g. theme-ui.
See: https://mui.com/material-ui/guides/theme-scoping/#using-with-theme-ui
Example:
The text was updated successfully, but these errors were encountered: