1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Remember TypedInput selected sub option when switching types

Fixes #2896
This commit is contained in:
Nick O'Leary 2021-03-10 17:50:46 +00:00
parent 99a9e3a91b
commit c37ea90206
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
2 changed files with 7 additions and 5 deletions

View File

@ -14,8 +14,8 @@
* limitations under the License.
**/
(function($) {
var contextParse = function(v) {
var parts = RED.utils.parseContextKey(v);
var contextParse = function(v,defaultStore) {
var parts = RED.utils.parseContextKey(v, defaultStore);
return {
option: parts.store,
value: parts.key
@ -829,7 +829,7 @@
} else {
var selectedOption = this.optionValue||opt.options[0];
if (opt.parse) {
var parts = opt.parse(this.input.val());
var parts = opt.parse(this.input.val(),selectedOption);
if (parts.option) {
selectedOption = parts.option;
if (!this.activeOptions.hasOwnProperty(selectedOption)) {

View File

@ -1070,7 +1070,7 @@ RED.utils = (function() {
return payload;
}
function parseContextKey(key) {
function parseContextKey(key, defaultStore) {
var parts = {};
var m = /^#:\((\S+?)\)::(.*)$/.exec(key);
if (m) {
@ -1078,7 +1078,9 @@ RED.utils = (function() {
parts.key = m[2];
} else {
parts.key = key;
if (RED.settings.context) {
if (defaultStore) {
parts.store = defaultStore;
} else if (RED.settings.context) {
parts.store = RED.settings.context.default;
}
}