From 1a9cce92940b6c0878729b59ee79d1897a4564f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 12 Feb 2024 08:40:45 +0100 Subject: [PATCH] MultiValueVariable: Fallback to value when text is missing --- .../variables/variants/MultiValueVariable.test.ts | 13 +++++++++++++ .../src/variables/variants/MultiValueVariable.ts | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/packages/scenes/src/variables/variants/MultiValueVariable.test.ts b/packages/scenes/src/variables/variants/MultiValueVariable.test.ts index 9f9876779..39e6d3b54 100644 --- a/packages/scenes/src/variables/variants/MultiValueVariable.test.ts +++ b/packages/scenes/src/variables/variants/MultiValueVariable.test.ts @@ -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', diff --git a/packages/scenes/src/variables/variants/MultiValueVariable.ts b/packages/scenes/src/variables/variants/MultiValueVariable.ts index b89ab3b4a..b088b802f 100644 --- a/packages/scenes/src/variables/variants/MultiValueVariable.ts +++ b/packages/scenes/src/variables/variants/MultiValueVariable.ts @@ -161,6 +161,10 @@ export abstract class MultiValueVariable