Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MultiValueVariable: Fallback to value when text is missing #591

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
13 changes: 13 additions & 0 deletions packages/scenes/src/variables/variants/MultiValueVariable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,19 @@ describe('MultiValueVariable', () => {
expect(variable.getValueText()).toBe(ALL_VARIABLE_TEXT);
});

it('GetValueText should return value if text is an empty string', async () => {
const variable = new TestVariable({
name: 'test',
options: [],
optionsToReturn: [],
value: 'MyValue',
text: '',
delayMs: 0,
});

expect(variable.getValueText()).toBe('MyValue');
});

it('GetValue should return all options as an array when value is $__all', async () => {
const variable = new TestVariable({
name: 'test',
Expand Down
4 changes: 4 additions & 0 deletions packages/scenes/src/variables/variants/MultiValueVariable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ export abstract class MultiValueVariable<TState extends MultiValueVariableState
return this.state.text.join(' + ');
}

if (this.state.text === '') {
return String(this.state.value);
}

return String(this.state.text);
}

Expand Down
Loading