-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[DataGrid][docs-infra] Fixing TailwindDemoContainer behaviour #18742
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
base: master
Are you sure you want to change the base?
Conversation
Deploy preview: https://deploy-preview-18742--material-ui-x.netlify.app/ Bundle size reportTotal Size Change: 0B(0.00%) - Total Gzip Change: 0B(0.00%) Show details for 100 more bundles (22 more not shown)@mui/x-charts parsed: 0B(0.00%) gzip: 0B(0.00%) |
Hey @KenanYusuf ,
It looks like this error may be related to 0ef47e1 |
Hi @sinore69 — I'm not sure this solution is working as expected, as it's created 100+ diffs in Argos. After digging into it a little, this line seems to be the issue. When the demo enters edit mode, I took a look to see if we fix the
I'm ok with disabling the live edit feature for this demo. At least users would be able to select the demo code without the page breaking. Looping in @cherniavskii since he helped with the implementation of this. |
Fixes #18725
Steps to reproduce:
Result:
Potential code area related to this issue:
The TailwindDemoContainer component dynamically loads Tailwind CSS by injecting a <script> tag. However, The script and styles were not being cleaned up on component unmount. While mounting/unmounting the component multiple times, Tailwind CSS remained in the DOM. This lead to unintended style bleed, memory leaks, or conflicts with other styles.
Solution logic:
Refactored the TailwindDemoContainer component to use global cache for loading the Tailwind CSS browser script.
Instead of injecting the script on every mount, the solution introduces shared global flags to track the loading state and reuse a single script load across all instances.
This ensures that the Tailwind script is only added once, avoids redundant requests, and eliminates performance issues caused by repeated injections.
The component now checks if the script is already loaded or in the process of loading, and uses a shared promise to coordinate multiple mounts.
This simplifies the component logic and makes the Tailwind loading mechanism more efficient and reliable.
Feedback on this PR is appreciated. Let me know if any changes or improvements are needed, happy to make updates if required!