The Wayback Machine - https://web.archive.org/web/20201128063656/https://github.com/mui-org/material-ui/issues/23693
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

[Select] When disabled the <input> element misses the disabled attribute #23693

Open
masoodusmani opened this issue Nov 23, 2020 · 2 comments
Open

Comments

@masoodusmani
Copy link

@masoodusmani masoodusmani commented Nov 23, 2020

  • 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 😯

When you create a <TextField select disabled />, the <input> element does not have the disabled prop, classes and aria-disabled="true" are added to the div to mark it as disabled

Expected Behavior 🤔

The input element should have the disabled prop

Steps to Reproduce 🕹

https://codesandbox.io/s/material-demo-forked-0n5s1?file=/demo.tsx

If you inspect the select field, the input element is not disabled, but it is disabled in the native select (though that's a select element)

Context 🔦

When a form field is disabled, its value is not supposed to be submitted when a form is submitted. I wanted to use that property to submit partial data, conditionally. Also, testing aria-disabled=true to check if it's disabled does not seem idiomatic.

Neither of these is very important, but the behaviour is unexpected when a regular TextField disables its input

Your Environment 🌎

Tech Version
Material-UI v5.0.0-alpha-17
React
Browser
TypeScript
etc.
@oliviertassinari
Copy link
Member

@oliviertassinari oliviertassinari commented Nov 23, 2020

@masoodusmani Thanks for the report, this looks accurate:

The disabled attribute is used to make the control non-interactive and to prevent its value from being submitted.

https://www.w3.org/TR/html51/sec-forms.html#element-attrdef-disabledformelements-disabled

What do you think about this diff? Do you want to work on a pull request? :)

diff --git a/packages/material-ui/src/Select/SelectInput.js b/packages/material-ui/src/Select/SelectInput.js
index ded48e9e1d..34244bb0ef 100644
--- a/packages/material-ui/src/Select/SelectInput.js
+++ b/packages/material-ui/src/Select/SelectInput.js
@@ -401,6 +401,7 @@ const SelectInput = React.forwardRef(function SelectInput(props, ref) {
         aria-hidden
         onChange={handleChange}
         tabIndex={-1}
+        disabled={disabled}
         className={classes.nativeInput}
         autoFocus={autoFocus}
         {...other}
@oliviertassinari oliviertassinari changed the title [TextField] with select and disabled, the input element does not have the disabled prop [Select] When disabled the <input> element does not have the disabled attribute Nov 23, 2020
@oliviertassinari oliviertassinari changed the title [Select] When disabled the <input> element does not have the disabled attribute [Select] When disabled the <input> element misses the disabled attribute Nov 23, 2020
@masoodusmani
Copy link
Author

@masoodusmani masoodusmani commented Nov 24, 2020

@oliviertassinari Looks good! I'd like to work on it, sure. I'll check the contributing guide today, and see if I can get set up later today.

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.