Material: select: form remains valid in a required md-select when empty option is selected

Created on 11 Nov 2016  路  4Comments  路  Source: angular/material

Actual Behavior:

  • What is the issue? *

    • mdSelect with "required" set in a form; use as empty option to clear select

    • select a non-empty option, form become valid

    • select empty option, form remains valid

  • What is the expected behavior?

    • form should become invalid

CodePen (or steps to reproduce the issue): *

Angular Versions: *

  • Angular Version: 1.5.5
  • Angular Material Version: 1.1.1

Additional Information:

  • Browser Type: * chrome
  • Browser Version: * latest
  • OS: * macOS
  • Stack Traces:
required Pull Request fixed bug

Most helpful comment

I guess if you're attempting to use these together, it does seem like the md-option-empty should indeed reset the validity of the model. However, I'll leave this to @ThomasBurleson's judgement as to whether or not this should be considered a bug.

All 4 comments

I don't think I am understanding your use-case. If the field is required, you shouldn't have any empty option right?

The requirement that I have designing the form is all select should have the an empty option to clear the select after user selecting a valid value. We just use this as the standard select across everywhere in the application regardless if the field is required or not

I guess if you're attempting to use these together, it does seem like the md-option-empty should indeed reset the validity of the model. However, I'll leave this to @ThomasBurleson's judgement as to whether or not this should be considered a bug.

This updated CodePen demonstrates how this is still an issue in 1.1.20 in addition to providing a side-by-side comparison to a regular select with AngularJS. This certainly seems like a bug that needs to be fixed.

Reference: https://stackoverflow.com/questions/12654631/why-does-angularjs-include-an-empty-option-in-select

Was this page helpful?
0 / 5 - 0 ratings