Skip to content

Commit 61459ea

Browse files
FrancescoMolinaroAndrea Barbasso
authored andcommitted
Merged in task/dspace-cris-2023_02_x/DSC-2005-fix (pull request DSpace#4757)
Task/dspace cris 2023 02 x/DSC-2005 fix Approved-by: Andrea Barbasso
2 parents 48b4c33 + 6c78ef9 commit 61459ea

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

src/app/shared/form/builder/ds-dynamic-form-ui/models/onebox/dynamic-onebox.component.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,19 @@ describe('DsDynamicOneboxComponent test suite', () => {
274274

275275
});
276276

277+
it('should clear inputValue when input is emptied after a value was set', () => {
278+
const inputDe = oneboxCompFixture.debugElement.query(By.css('input.form-control'));
279+
const inputElement = inputDe.nativeElement;
280+
281+
inputElement.value = 'test value';
282+
inputElement.dispatchEvent(new Event('input'));
283+
expect(oneboxComponent.inputValue).toEqual(new FormFieldMetadataValueObject('test value'));
284+
285+
inputElement.value = '';
286+
inputElement.dispatchEvent(new Event('input'));
287+
expect(oneboxComponent.inputValue).toBeNull();
288+
});
289+
277290
it('should emit blur Event onBlur when popup is closed', () => {
278291
spyOn(oneboxComponent.blur, 'emit');
279292
spyOn(oneboxComponent.instance, 'isPopupOpen').and.returnValue(false);

src/app/shared/form/builder/ds-dynamic-form-ui/models/onebox/dynamic-onebox.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ export class DsDynamicOneboxComponent extends DsDynamicVocabularyComponent imple
180180
this.inputValue.securityLevel = (this.model.value as any).securityLevel;
181181
}
182182
}
183+
} else if (isEmpty(event.target.value)) {
184+
this.inputValue = null;
183185
}
184186
}
185187

0 commit comments

Comments
 (0)