diff --git a/packages/core/src/forms/mapObjectEditor/mapObjectEditor.component.js b/packages/core/src/forms/mapObjectEditor/mapObjectEditor.component.js index b48863cdc42..651e0980627 100644 --- a/packages/core/src/forms/mapObjectEditor/mapObjectEditor.component.js +++ b/packages/core/src/forms/mapObjectEditor/mapObjectEditor.component.js @@ -20,7 +20,7 @@ angular return JSON.parse(input); } function out(data) { - return JSON.stringify(data); + return JSON.stringify(data, null, 2); } ngModel.$parsers.push(into); ngModel.$formatters.push(out); @@ -47,7 +47,7 @@ angular const modelKeys = () => Object.keys(this.model); this.addField = () => { - this.backingModel.push({ key: '', value: '', checkUnique: modelKeys() }); + this.backingModel.push({ key: '', value: {}, checkUnique: modelKeys() }); // do not fire the onChange event, since no values have been committed to the object }; diff --git a/packages/core/src/forms/mapObjectEditor/mapObjectEditor.component.spec.js b/packages/core/src/forms/mapObjectEditor/mapObjectEditor.component.spec.js index 192995d6f14..b18b21c7776 100644 --- a/packages/core/src/forms/mapObjectEditor/mapObjectEditor.component.spec.js +++ b/packages/core/src/forms/mapObjectEditor/mapObjectEditor.component.spec.js @@ -26,32 +26,6 @@ describe('Component: mapObjectEditor', function () { expect(dom.find('textarea').get(1).value).toBe('11'); }); - describe('empty value handling', function () { - it('ignores empty values when synchronizing to the model', function () { - scope.model = { foo: { bar: 'baz' }, bah: 11 }; - let dom = this.compile('')(scope); - scope.$digest(); - - $(dom.find('textarea')[1]).val('').change(); - scope.$digest(); - - expect(scope.model.foo).toEqual({ bar: 'baz' }); - expect(scope.model.bah).toBeUndefined(); - }); - - it('writes empty values when allowEmpty flag is set', function () { - scope.model = { foo: { bar: 'baz' }, bah: 11 }; - let dom = this.compile('')(scope); - scope.$digest(); - - $(dom.find('textarea')[1]).val('').change(); - scope.$digest(); - - expect(scope.model.foo).toEqual({ bar: 'baz' }); - expect(scope.model.bah).toBe(''); - }); - }); - describe('adding new entries', function () { it('creates a new row in the table, but does not synchronize to model', function () { scope.model = {};