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 does not allow for a required attribute #11836

Closed
2 tasks done
mymattcarroll opened this issue Jun 12, 2018 · 5 comments
Closed
2 tasks done

Select does not allow for a required attribute #11836

mymattcarroll opened this issue Jun 12, 2018 · 5 comments
Assignees
Labels
component: select This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation

Comments

@mymattcarroll
Copy link

@material-ui/core/Select does not allow for a required attribute like @material-ui/core/TextField

  • This is a v1.x issue (v0.x is no longer maintained).
  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

Should be able to add required attribute to the <Select> input and it should:

  • Add * to label
  • Add required attribute to the rendered <input> tag

Current Behavior

Currently no support for required attribute on <Select> tags

Steps to Reproduce (for bugs)

https://codesandbox.io/s/qx4x1w8qlj

  1. Add <Select> input with required attribute

Context

Would like <Select> inputs to act like <TextField> inputs to make UI consistent

Your Environment

Tech Version
Material-UI v1.0.0
React v16.3.2
browser Chrome
@oliviertassinari oliviertassinari added the component: select This is the name of the generic UI component, not the React module! label Jun 13, 2018
@oliviertassinari oliviertassinari self-assigned this Jun 13, 2018
@oliviertassinari oliviertassinari added the docs Improvements or additions to the documentation label Jun 13, 2018
@mciparelli
Copy link

@oliviertassinari looks like the non-native solution uses a type=hidden input so the required validation won't really run unfortunately. Attempting to change it to type=text in inputProps results in the following error:

Warning: Failed prop type: You provided a value prop to a form field without an onChange handler.

@oliviertassinari
Copy link
Member

@mciparelli If you are looking for the native require validation logic, use the native implementation of the select.

@mciparelli
Copy link

Well it's a shame because it would be nice to be able to still have the chance to use the custom select look and feel without losing the HTML5 validation.

@oliviertassinari
Copy link
Member

@mciparelli Let us know if you find a way to change the implementation to get this done. But I have some doubt that we can achieve it.

@oliviertassinari

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: select This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation
Projects
None yet
Development

No branches or pull requests

3 participants