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

[TextField] No state class applied for readonly state #33613

Closed
2 tasks done
noobDev31 opened this issue Jul 22, 2022 · 8 comments · Fixed by #33654
Closed
2 tasks done

[TextField] No state class applied for readonly state #33613

noobDev31 opened this issue Jul 22, 2022 · 8 comments · Fixed by #33654
Labels
bug 🐛 Something doesn't work component: text field This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material

Comments

@noobDev31
Copy link

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

I am trying to achieve the following permutation of styles with the Material UI TextField -

image

I am trying to remove the border of the input whenever I do readonly:true for the TextField.

But it doesn't take any effect and the reason can be that disabled and readonly are both getting the same CSS class.

Expected behavior 🤔

Readonly and Disabled should have a seperate CSS class so that they can targeted differently.

Sandbox - https://codesandbox.io/s/customizedinputs-demo-material-ui-forked-2unmw9?file=/index.tsx:809-870

Steps to reproduce 🕹

Steps:

1.Please open the following sandbox -
https://codesandbox.io/s/customizedinputs-demo-material-ui-forked-2unmw9?file=/index.tsx:809-870
and try giving the props -

InputProps={{ readOnly: true }}
to the LowCodeTextField component at index.tsx

2.The border doesn't get removed even though I have the class in the ThemeProviderconfig.ts
3.
4.

Context 🔦

No response

Your environment 🌎

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.
@noobDev31 noobDev31 added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jul 22, 2022
@hbjORbj hbjORbj added component: text field This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material labels Jul 22, 2022
@noobDev31
Copy link
Author

Hi @hbjORbj any eta for this?

@michaldudak michaldudak changed the title Material UI TextField doesn't have a way to differentiate readonly and disabled input [TextField] No state class applied for readonly state Jul 26, 2022
@michaldudak
Copy link
Member

Thanks for the report @noobDev31. We could indeed use a class for the read-only state of the Input, to match the behavior of other states.

@michaldudak michaldudak added bug 🐛 Something doesn't work and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jul 26, 2022
@noobDev31
Copy link
Author

noobDev31 commented Jul 26, 2022

No issues @michaldudak. I just one need favor from you do you think this code -

image

is the right way( passing label as null to the TextField) to achieve to these designs -
image

or should I have broken the TextField the way the docs mentions - its made up of InputLabel, Input and FormHelperText and style all three of them separately.

@michaldudak
Copy link
Member

You're losing association between label and input this way. Note that a label must have the for attribute or have the control it describes as its child.

@noobDev31
Copy link
Author

So now we have a CSS class for the readonly?

@michaldudak
Copy link
Member

After we release the next version (likely the next Monday).

@noobDev31
Copy link
Author

Well thanks a lot for this 😊

@oliviertassinari
Copy link
Member

Related to #9790.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: text field This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants