diff --git a/grafana/templates/custom.js b/grafana/templates/custom.js index 3a7da4c..46c7fc5 100644 --- a/grafana/templates/custom.js +++ b/grafana/templates/custom.js @@ -92,7 +92,7 @@ Custom.prototype._processOptions = function _processOptions() { throw new SyntaxError("default value not found in options list") } this.state.current = defaultOption - } else if (!this.state.current && !this.state.includeAll) { + } else if (!this.state.current) { this.state.current = newOptions[0]; } diff --git a/test/templates/custom.js b/test/templates/custom.js index ae7fef7..7826222 100644 --- a/test/templates/custom.js +++ b/test/templates/custom.js @@ -106,14 +106,14 @@ test('Custom template overwrites default state', function t(assert) { assert.equal(customWithAllValue.state.current, null); assert.equal(customWithAllValue.state.allValue, 'grafana') - var allIsDefault = new Custom({ + var firstIsDefaultWithAll = new Custom({ includeAll: true, arbitraryProperty: 'foo', options: [{ text: 'grafana', value: 'grafana' }] }); - assert.equal(allIsDefault.state.includeAll, true); - assert.equal(allIsDefault.state.allValue, '') - assert.equal(allIsDefault.state.current, null); + assert.equal(firstIsDefaultWithAll.state.includeAll, true); + assert.equal(firstIsDefaultWithAll.state.allValue, '') + assert.equal(firstIsDefaultWithAll.state.current, firstIsDefaultWithAll.state.options[0]); var firstIsDefault = new Custom({ arbitraryProperty: 'foo',