diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/tag/dynamic-tag.component.spec.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/models/tag/dynamic-tag.component.spec.ts index a6a4c451700..2e5feaba079 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/tag/dynamic-tag.component.spec.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/tag/dynamic-tag.component.spec.ts @@ -22,10 +22,11 @@ import { mockDynamicFormValidationService } from '../../../../../testing/dynamic-form-mock-services'; -function createKeyUpEvent(key: number) { +function createKeyUpEvent(key: number, keyName: string) { /* eslint-disable no-empty,@typescript-eslint/no-empty-function */ const event = { - keyCode: key, preventDefault: () => { + keyCode: key, + key: keyName, preventDefault: () => { }, stopPropagation: () => { } }; @@ -257,7 +258,7 @@ describe('DsDynamicTagComponent test suite', () => { }); it('should add an item on ENTER or key press is \',\' or \';\'', fakeAsync(() => { - let event = createKeyUpEvent(13); + let event = createKeyUpEvent(13,'Enter'); tagComp.currentValue = 'test value'; tagFixture.detectChanges(); @@ -268,7 +269,7 @@ describe('DsDynamicTagComponent test suite', () => { expect(tagComp.model.value).toEqual(['test value']); expect(tagComp.currentValue).toBeNull(); - event = createKeyUpEvent(188); + event = createKeyUpEvent(188,','); tagComp.currentValue = 'test value'; tagFixture.detectChanges(); diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/tag/dynamic-tag.component.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/models/tag/dynamic-tag.component.ts index 7c3d8982e1a..e7119a424ec 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/tag/dynamic-tag.component.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/tag/dynamic-tag.component.ts @@ -184,7 +184,7 @@ export class DsDynamicTagComponent extends DsDynamicVocabularyComponent implemen * @param event the keyUp event */ onKeyUp(event) { - if (event.keyCode === 13 || event.keyCode === 188) { + if (event.keyCode === 13 || (event.key.includes(',') && event.keyCode === 188) || ((event.key as string).includes(';') && event.keyCode === 186) ) { event.preventDefault(); // Key: 'Enter' or ',' or ';' this.addTagsToChips();