Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion grafana/templates/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Contributor

@najisawas najisawas Mar 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure this will break includeAll. For example if includeAll == true then it will get ignored and the dash will default to the newOptions[0], right?

i remember playing with something related to this area in grafana. I would recommend looking into how current is set when theres no allValue. For example if the allValue is "" i believe current is set to null. But if there is an allValue then it's used

this.state.current = newOptions[0];
}

Expand Down
8 changes: 4 additions & 4 deletions test/templates/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down