From 15b52a5d25025c4599418a649c49f9ac782f50f1 Mon Sep 17 00:00:00 2001 From: bordun Date: Sat, 8 May 2021 16:02:18 +0200 Subject: [PATCH] advanced syntaxes (VAR{}): avoid storing default value as string if it can be parsed as a javascript primitive (boolean, number, etc) --- CHANGELOG.md | 1 + src/client/widgets/common/widget.js | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c9f35532..8d15c11e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - bug fixes - issue when resizing widget using keyboard shortcuts + - advanced syntaxes (VAR{}): avoid storing default value as string if it can be parsed as a javascript primitive (boolean, number, etc) - editor - change keyboard shortcuts for moving widgets (now `mod + arrows`) and navigating in widgets (now `arrows`) to feel more natural with the project tree view. diff --git a/src/client/widgets/common/widget.js b/src/client/widgets/common/widget.js index 6491f684..3f26c56b 100644 --- a/src/client/widgets/common/widget.js +++ b/src/client/widgets/common/widget.js @@ -638,6 +638,12 @@ class Widget extends EventEmitter { return typeof variables[m] === 'string' ? variables[m] : JSON.stringify(variables[m]) })) + if (typeof value === 'string' && isJSON(value)) { + try { + value = JSON.parseFlex(value) + } catch (err) {} + } + if (!this.variables[name]) { this.variables[name] = {default: value, value: value, propNames: [propName]}