Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Conversation

devversion
Copy link
Member

  • Currently when using required on the select, is adding the required validator to the ngModelCtrl.
    The required validator is checking the $viewValueby using the $isEmpty function, which is overwritten
    by the select component.

    $isEmpty normally checks just for truthy values, but our custom $isEmpty function checks the value for being a registered option.
    This does not work, because we are just trying to find the value in the options object.
    Once the the value is also an object, we are not able to find the option (which is wrong). All options inside of the variable are stored within their
    associated hashkey.

    That's why we have to retrieve the hashkey of the current value. This is also required for ngModel's with a trackBy option.

  • Once an option is set to the ngModel, before the actual md-option directive is registered, the required validator will be set to false.
    We have to trigger a new validation, when the option, which is currently the $modelValue, has been registered.

Fixes #8666.

Please review @topherfangio @crisbeto

* Currently when using `required` on the select, is adding the required validator to the ngModelCtrl.
  The required validator is checking the `$viewValue`by using the `$isEmpty` function, which is overwritten
  by the select component.

  `$isEmpty` normally checks just for truthy values, but our custom `$isEmpty` function checks the value for being a registered option.
  This does not work, because we are just trying to find the value in the options object.
  Once the the value is also an object, we are not able to find the option (which is wrong). All options inside of the variable are stored within their
  associated hashkey.

  That's why we have to retrieve the hashkey of the current value. This is also required for ngModel's with a `trackBy` option.

* Once an option is set to the ngModel, before the actual `md-option` directive is registered, the required validator will be set to `false`.
  We have to trigger a new validation, when the option, which is currently the $modelValue, has been registered.

Fixes angular#8666.
@devversion devversion added the needs: review This PR is waiting on review from the team label Jun 14, 2016
@crisbeto
Copy link
Member

LGTM

@ThomasBurleson ThomasBurleson added pr: merge ready This PR is ready for a caretaker to review and removed needs: review This PR is waiting on review from the team labels Jun 20, 2016
@devversion devversion deleted the fix/select-hashkey-validation branch June 20, 2016 14:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pr: merge ready This PR is ready for a caretaker to review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants