Skip to content

Commit 4f6a7c1

Browse files
[DSC-2005] fix one box clear on input
1 parent 11797a2 commit 4f6a7c1

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

296296
});
297297

298+
it('should clear inputValue when input is emptied after a value was set', () => {
299+
const inputDe = oneboxCompFixture.debugElement.query(By.css('input.form-control'));
300+
const inputElement = inputDe.nativeElement;
301+
302+
inputElement.value = 'test value';
303+
inputElement.dispatchEvent(new Event('input'));
304+
expect(oneboxComponent.inputValue).toEqual(new FormFieldMetadataValueObject('test value'));
305+
306+
inputElement.value = '';
307+
inputElement.dispatchEvent(new Event('input'));
308+
expect(oneboxComponent.inputValue).toBeNull();
309+
});
310+
298311
it('should emit blur Event onBlur when popup is closed', () => {
299312
spyOn(oneboxComponent.blur, 'emit');
300313
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
@@ -243,6 +243,8 @@ export class DsDynamicOneboxComponent extends DsDynamicVocabularyComponent imple
243243
this.inputValue.securityLevel = (this.model.value as any).securityLevel;
244244
}
245245
}
246+
} else if (isEmpty(event.target.value)) {
247+
this.inputValue = null;
246248
}
247249
}
248250

0 commit comments

Comments
 (0)