material icon indicating copy to clipboard operation
material copied to clipboard

mdSelect: error handling of mdSelect is inconsistent with mdInput

Open montgomery1944 opened this issue 10 years ago • 6 comments

There is a couple of issues with current mdSelect error handling:

  1. Default error getter implementation for mdSelect does not take into consideration the $submitted property from parent form like mdInput does. This leads to inconsistent and confusing behaviour when submitting form containing select and input with errors.
  2. mdInput placeholder, border and message are red when the input has error. mdSelect error styling is applied only when dirty. This is inconsistent and confusing when using mdinput and mdSelect in the same form.
  3. mdSelect does not get the asterisk after the placeholder when required.

Demo can be found at http://codepen.io/anon/pen/wGeyem.

Tested with jQuery 2.2.2, Angular 1.5.2 and Angular Material 1.1.0-rc1.

I can provide a pull request with fixes for those issues, including tests, if this is going to help.

montgomery1944 avatar Mar 27 '16 13:03 montgomery1944

I am using Angular Material ^1.0.6 and I have a similar issue. The md-select and regular text input both have the required attribute.

  • When the user leaves both fields blank and submits the form, the ng-message shows up for the text input and not for the md-select input.
  • When the user clicks on the md-select, the ng-message appears.
    • The ng-message appears even before the user chooses a md-option.
  • The ng-message appears even after choosing an md-option.

AskYous avatar Mar 28 '16 17:03 AskYous

I can confirm these issues occur using angular material 1.1.0-rc1 and angular 1.5.2. Has anybody figured out a temporary work around?

sbehun avatar Mar 30 '16 14:03 sbehun

I will start working on PR for those issues.

montgomery1944 avatar Mar 31 '16 17:03 montgomery1944

Probably there is the same issue in md-checkbox too: http://plnkr.co/edit/iLYAHM55U1SRhxHNe7au

michelem09 avatar Apr 01 '16 10:04 michelem09

@montgomery1944 How do you plan to fix this? The input component prevents the from submit by the browser defaults. Select and Checkbox are custom elements.

Basically the form, can be submitted through:

<form name="test" ng-submit="test.$valid && ctrl.submitForm()">

devversion avatar Apr 01 '16 12:04 devversion

This issue is closed as part of our ‘Surge Focus on Material 2' efforts. For details, see our forum posting @ http://bit.ly/1UhZyWs.

ThomasBurleson avatar Jun 02 '16 07:06 ThomasBurleson