Skip to content

Commit

Permalink
template: fix validation for required selects
Browse files Browse the repository at this point in the history
Since upgrading to Angular 1.6.1, selects with a default empty option
no longer show a popup with an error on submit. This fix adds an
empty option that is then removed with ng-if. Having the default
option set to null or undefined seems to be the cause of the bug.

The list of changes in 1.6 is here but could not find any obvious
cause for this bug:

https://docs.angularjs.org/guide/migration#migrating-from-1-5-to-1-6
  • Loading branch information
daniellee committed Mar 21, 2017
1 parent f78a283 commit 5ecc8a1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions public/app/features/templating/partials/editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ <h5 class="section-heading">Query Options</h5>
<div class="gf-form max-width-21">
<span class="gf-form-label width-7">Data source</span>
<div class="gf-form-select-wrapper max-width-14">
<select class="gf-form-input" ng-model="current.datasource" ng-options="f.value as f.name for f in datasources" required></select>
<select class="gf-form-input" ng-model="current.datasource" ng-options="f.value as f.name for f in datasources" required>
<option value="" ng-if="false"></option>
</select>
</div>
</div>
<div class="gf-form max-width-21">
Expand Down Expand Up @@ -230,7 +232,9 @@ <h5 class="section-heading">Options</h5>
<div class="gf-form max-width-21">
<span class="gf-form-label width-8">Data source</span>
<div class="gf-form-select-wrapper max-width-14">
<select class="gf-form-input" ng-model="current.datasource" ng-options="f.value as f.name for f in datasources" required ng-change="validate()"></select>
<select class="gf-form-input" ng-model="current.datasource" ng-options="f.value as f.name for f in datasources" required ng-change="validate()">
<option value="" ng-if="false"></option>
</select>
</div>
</div>
</div>
Expand Down

0 comments on commit 5ecc8a1

Please sign in to comment.