Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Port dspace-7_x] Fixes Incorrect operation of the keyword selection field with < and , on the Submission page #3108

Open
wants to merge 3 commits into
base: dspace-7_x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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: () => {
}
};
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading