mui / mui/material-ui

[material-ui] Styles does not apply in same order

Open
#36,211 1 comment 0 reactions 1 assignee View on GitHub

@mnajdova is already working on this.

Since Feb 16, 2023.

scope: text field support: question
Dominant language
JavaScript
Stars
99.1k
Forks
32.5k
Avg merge
2d 17h
Merged PRs (30d)
106

Description

Duplicates
  • I have searched the existing issues
Latest version
  • I have tested the latest version
Steps to reproduce 🕹

Link to live example: https://codesandbox.io/s/nifty-night-37fimk?file=/src/App.tsx

Steps:

  1. Customize e.g. TextField background (filled variant) by adding & .MuiFilledInput-root { background: "white" }
  2. Check how it render and how hover/focus behave (hover and focus from Mui override our custom background white) (Screen 1)
  3. Now add original Mui TextField before the customized one and refresh page. Now check how the hover/active behave (hover and focus from Mui now DOES NOT override our custom background white - our custom style has higher priority than before) (Screen 2)

Screen 1:
image

Screen 2:
image

Current behavior 😯

Custom styled element does not always looks the same.

Expected behavior 🤔

Custom styled element should always looks the same.

Context 🔦

Want to the same styles always behave in the same way. Want styled element to be deterministic - the same style do the same thing every time.

Your environment 🌎
npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.
  
  Browser: Chrome 109
  
  "dependencies": {
    "@emotion/react": "11.10.5",
    "@emotion/styled": "11.10.5",
    "@mui/material": "5.11.8",
    "react": "18.0.0",
    "react-dom": "18.0.0",
    "react-scripts": "4.0.3"
  },

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.