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

Styles order depends on script execution order #19489

Closed
2 tasks done
panfiva opened this issue Jan 30, 2020 · 2 comments
Closed
2 tasks done

Styles order depends on script execution order #19489

panfiva opened this issue Jan 30, 2020 · 2 comments

Comments

@panfiva
Copy link

panfiva commented Jan 30, 2020

Custom styles that are generated using makeStyles() function are sometimes applied before core styles

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

Current Behavior 😯

Custom style created using makeStyles is applied before core MuiTab style. As the result, some of the custom properties are overwritten using default library properties. This causes incorrect capitalization and width of tabs.

image

Tab remains capitalized and wide. Should be narrower and have lowercase letters.

Expected Behavior 🤔

When applying custom styles, they should apply after core MUI styles to properly overwrite them. In the image below, both tabs should have lower case letters with maximum width of 50
image

In the picture above, both Tabs 1 and Tabs 2 elements should have the same width (max 50px) and capitalization (should have lowercase)

Steps to Reproduce 🕹

Steps:

  1. Load https://codesandbox.io/s/tab-styles-issue-fyxql?fontsize=14&hidenavigation=1&theme=dark
  2. Notice that both tabs 1 and tabs 2 folders contain exactly the same files and should produce tabs with max-width=50 and lowercase letters; Tabs 1 is formatted with material ui defaults.
  3. Edit Home.js file and move line 9 before line 8
    image
  4. Notice that now Tab 1 is formatted correctly; however Tab2 is no longer correctly formatted.

Context 🔦

I am trying to make sure that styles are applied correctly to application. As I was building the page, I was having issues in the production; however the sample included also contains issues in my DEV environment.

Your Environment 🌎

Tech Version
Material-UI v4.9.0
React 16.12.0
Browser Chrome 79.0.3945.130
TypeScript javascript
Application is configured using the latest create-react-app script (downloaded yesterday)
@oliviertassinari
Copy link
Member

oliviertassinari commented Jan 30, 2020

@panfiva This looks expected, the injection order depends on the script execution order. I believe you would get a similar experience with react-jss or styled-components. You could get a more predictable outcome by removing the circular import.

-import { Tab } from './index';
+import Tab from './tab';

There is almost no longer-term benefit it better documenting it considering we will offload the style engine to thrid-parties in v5 (which we already with JSS to be honest).

I hope it helps, we appreciate you took the time to create a reproduction :). I remember a similar discussion with @NMinhNguyen in the past.

@oliviertassinari oliviertassinari changed the title Styles are not applied properly (incorrect order of styles) Styles order depends on script execution Jan 30, 2020
@oliviertassinari oliviertassinari changed the title Styles order depends on script execution Styles order depends on script execution order Jan 30, 2020
@panfiva
Copy link
Author

panfiva commented Jan 31, 2020

thank you so much... it helped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants