Skip to content

Commit d2d9f87

Browse files
FrancescoMolinaroAndrea Barbasso
authored andcommitted
Merged in task/dspace-cris-2025_02_x/DSC-2005-fix (pull request DSpace#4759)
[DSC-2005] fix one box clear on input Approved-by: Andrea Barbasso
2 parents aecabbd + bba2666 commit d2d9f87

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
@@ -293,6 +293,19 @@ describe('DsDynamicOneboxComponent test suite', () => {
293293

294294
});
295295

296+
it('should clear inputValue when input is emptied after a value was set', () => {
297+
const inputDe = oneboxCompFixture.debugElement.query(By.css('input.form-control'));
298+
const inputElement = inputDe.nativeElement;
299+
300+
inputElement.value = 'test value';
301+
inputElement.dispatchEvent(new Event('input'));
302+
expect(oneboxComponent.inputValue).toEqual(new FormFieldMetadataValueObject('test value'));
303+
304+
inputElement.value = '';
305+
inputElement.dispatchEvent(new Event('input'));
306+
expect(oneboxComponent.inputValue).toBeNull();
307+
});
308+
296309
it('should emit blur Event onBlur when popup is closed', () => {
297310
spyOn(oneboxComponent.blur, 'emit');
298311
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
@@ -238,6 +238,8 @@ export class DsDynamicOneboxComponent extends DsDynamicVocabularyComponent imple
238238
this.inputValue.securityLevel = (this.model.value as any).securityLevel;
239239
}
240240
}
241+
} else if (isEmpty(event.target.value)) {
242+
this.inputValue = null;
241243
}
242244
}
243245

0 commit comments

Comments
 (0)