diff --git a/src/js/form-builder.js b/src/js/form-builder.js index f242756cc..1761fdfe3 100644 --- a/src/js/form-builder.js +++ b/src/js/form-builder.js @@ -701,7 +701,7 @@ function FormBuilder(opts, element, $) { const attrValType = userAttrType(typeUserAttr[attribute]) if (attrValType !== 'undefined') { const orig = mi18n.get(attribute) - const tUA = typeUserAttr[attribute] + const tUA = Object.assign({}, typeUserAttr[attribute]) //Ensure we work on a copy of the attributes let origValue = tUA.value if (attrValType === 'boolean') { tUA[attribute] ??= tUA.value @@ -722,7 +722,6 @@ function FormBuilder(opts, element, $) { } i18n[attribute] = orig - tUA.value = origValue } else if (attrValType === 'undefined' && hasSubType(values, attribute)) { advField.push(processTypeUserAttrs(typeUserAttr[attribute], values)) } else { diff --git a/tests/form-builder.test.js b/tests/form-builder.test.js index 45457d511..359c6dc4d 100644 --- a/tests/form-builder.test.js +++ b/tests/form-builder.test.js @@ -524,7 +524,7 @@ describe('FormBuilder typeUserAttrs detection', () => { 'blue form-control': 'Blue' }, style: 'border: 1px solid red', - value: 'Red', + value: 'red form-control', } }, }, @@ -543,6 +543,43 @@ describe('FormBuilder typeUserAttrs detection', () => { expect(input.val()).toEqual('green form-control') }) + test('fix GH-1534', async() => { + const config = { + typeUserAttrs: { + '*': { + className: { + label: 'Class', + multiple: false, + options: { + 'red form-control': 'Red', + 'green form-control': 'Green', + 'blue form-control': 'Blue' + }, + style: 'border: 1px solid red', + value: 'red form-control', + } + }, + }, + } + const fbWrap = $('