diff --git a/src/process/normalize/__tests__/normalize.test.ts b/src/process/normalize/__tests__/normalize.test.ts index e56e0b2d..4aa78b07 100644 --- a/src/process/normalize/__tests__/normalize.test.ts +++ b/src/process/normalize/__tests__/normalize.test.ts @@ -6,6 +6,7 @@ import { ProcessorContext, ProcessorScope, DayComponent, + TagsComponent, } from 'types'; import { normalizeProcessSync } from '../'; import { generateProcessorContext } from '../../__tests__/fixtures/util'; @@ -338,4 +339,21 @@ describe('Normalize processor', function () { normalizeProcessSync(context); expect({ day: '01/2025' }).to.deep.equal({ day: '01/2025' }); }); + + it('Should remove the tag component from the submission object if data is set to null', async function () { + const tagsComponent: TagsComponent = { + input: true, + delimeter: '', + maxTags: 1, + storeas: '', + type: 'tags', + key: 'tags', + }; + const data = { + tags: null, + }; + const context: ProcessorContext = generateProcessorContext(tagsComponent, data); + normalizeProcessSync(context); + expect(context.data).to.deep.equal({}); + }); }); diff --git a/src/process/normalize/index.ts b/src/process/normalize/index.ts index 332deb6a..38de3525 100644 --- a/src/process/normalize/index.ts +++ b/src/process/normalize/index.ts @@ -394,6 +394,9 @@ export const normalizeProcessSync: ProcessorFnSync = (context) = scope.normalize[path].normalized = true; } else if (isTagsComponent(component)) { set(data, path, normalizeTagsComponentValue(component, value)); + if (data[path] === null) { + delete data[path]; + } scope.normalize[path].normalized = true; } else if (isTextFieldComponent(component)) { set(data, path, normalizeTextFieldComponentValue(component, defaultValues, value, path));