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

[utils] Handle circular reference of objects in deepMerge #38647

Closed
wants to merge 5 commits into from

Conversation

sai6855
Copy link
Contributor

@sai6855 sai6855 commented Aug 26, 2023

closes: #38489

reason for crashing of Autocomplete in before sandbox is explained here: #38489 (comment)

before: https://codesandbox.io/s/late-wind-9fzfmw?file=/Demo.js
after: https://codesandbox.io/s/still-framework-57wl4g?file=/Demo.js

@sai6855 sai6855 marked this pull request as draft August 26, 2023 04:29
@sai6855 sai6855 added bug 🐛 Something doesn't work package: utils Specific to the @mui/utils package labels Aug 26, 2023
@sai6855 sai6855 changed the title [utils] Support circular reference of objects in deepMerge [utils] Handle circular reference of objects in deepMerge Aug 26, 2023
@mui-bot
Copy link

mui-bot commented Aug 26, 2023

Netlify deploy preview

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

Bundle size report

Details of bundle changes (Toolpad)
Details of bundle changes

Generated by 🚫 dangerJS against 466ef56

@sai6855 sai6855 marked this pull request as ready for review August 26, 2023 05:00
if (!isPlainObject(source)) {
return source;
}

const output: Record<keyof any, unknown> = {};

Object.keys(source).forEach((key) => {
output[key] = deepClone(source[key]);
if (!visited.has(source[key])) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I get that this fix is not really cloning circular objects, but I can't think of a better way to handle circular objects

@sai6855 sai6855 requested review from mnajdova and mj12albert August 26, 2023 16:47
@sai6855 sai6855 closed this Aug 27, 2023
@siriwatknp
Copy link
Member

The alternative way is checking the React element which has been merged #44400

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work package: utils Specific to the @mui/utils package
Projects
None yet
3 participants