question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

createMuiTheme overrides not working since 4.9.6

See original GitHub issue

createMuiTheme overrides not working since 4.9.6

Since https://github.com/mui-org/material-ui/issues/20095, the isPlainObject has been modified. Testing constructorproperty is not multi-frame proof. This makes deepmerge do not merge incomming properties from given source when source is an Object created in another js context like another document iframe.

  • [X ] The issue is present in the latest release.
  • [ X] I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

The generated jss style does not conatin overrides, so desired style is not applied to components.

Expected Behavior 🤔

The generated jss style must contain overrides in order to have the desired styles applied to components.

Tech Version
Material-UI v4.1.11
React 16.14
Browser all
TypeScript no
etc.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
oliviertassinaricommented, Nov 27, 2020

Why change it in this particular instance?

@eps1lon I’m asking because it doesn’t seem to be something we fundamentally prevent from supporting. As far as I know, It’s not blocking. Developers can bypass the deepmerge method, by bypassing the createMuiTheme() method. Hence why I’m eager to have a reproduction to better understand the use case.

We know that multi-frame support is rarely used but we still support it. I suspect this specific case is unique and nonblocking. A drop in the bucket most developers would rather have us ignore (not pay the cost for it). Not every bug deserved to be fixed. I think that it’s a big factor in the “write your own” popularity, it allows different tradeoffs (but also come with ignoring problems you don’t know you have).

2reactions
fbaetacommented, Nov 27, 2020

https://github.com/mui-org/material-ui/pull/23740#issuecomment-734486617

https://github.com/jonschlinkert/is-plain-object might also be a source of inspiration. My main concern is about adding bundle size for edge case almost nobody needs. You can modify the theme outside of the createMuiTheme() method.

Before all, thanks for your fast reply!

I understand that edge cases do not justify increasing bundle size 👍.

I’ve created a PR just to show the case, the goal was not really o be merged 😉 (the isPlainObject code is borrowed from lodash). I wanted to point out that:

  • Using constructor to test if it’s a plain object is not the more resilient technique and should be reconsidered. If you don’t like lodash implementation, as you said, you might find other techniques. This change was introduced here https://github.com/mui-org/material-ui/issues/20095, so if in v5 you are planning to remove support of this popper version, you sould reconsider (again) to not use constructor technique.
  • The isPlainObject is poorly tested.

In my current case, I CAN NOT upgrade material-ui up to 4.9.5 for now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

createMuiTheme overrides not working since 4.9.6 #23739
The generated jss style must contain overrides in order to have the desired styles applied to components. Tech, Version. Material-UI, v4.1.11.
Read more >
Material UI Select override Position in theme - reactjs
The overrides key is for overriding styles. You should use the props key for defaulting props in the theme. Here's the correct syntax:...
Read more >
can't resolve '@material-ui/core/styles/createmuitheme'
MaterialUI TextField : changing background color is not working as it is ... You can instead override the background-color on the FilledInput as...
Read more >
material-ui/core/CHANGELOG.md
8, Please report issues with the deprecations on ... 219, - Simplify the theme overrides with TypeScript for the components in the lab...
Read more >
override input styling from theme
override input styling from theme ... Activating extension 'vscode.typescript-language-features' failed: Could not find bundled tsserver.js.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found