diff --git a/packages/custom-field/src/vaadin-custom-field-mixin.js b/packages/custom-field/src/vaadin-custom-field-mixin.js index 190c4981b8..8c45816471 100644 --- a/packages/custom-field/src/vaadin-custom-field-mixin.js +++ b/packages/custom-field/src/vaadin-custom-field-mixin.js @@ -272,6 +272,9 @@ export const CustomFieldMixin = (superClass) => /** @private */ __inputsChanged(inputs, oldInputs) { if (inputs.length === 0) { + if (oldInputs && oldInputs.length > 0) { + this.__setValue(); + } return; } diff --git a/packages/custom-field/test/custom-field.common.js b/packages/custom-field/test/custom-field.common.js index 7f019e212d..b266a223d4 100644 --- a/packages/custom-field/test/custom-field.common.js +++ b/packages/custom-field/test/custom-field.common.js @@ -88,6 +88,19 @@ describe('custom field', () => { expect(el.value).to.equal(''); }); }); + + it('should update value when removing inputs', async () => { + customField.value = '1\t1'; + await nextUpdate(customField); + + customField.removeChild(customField.inputs[0]); + await nextUpdate(customField); + expect(customField.value).to.equal('1'); + + customField.removeChild(customField.inputs[0]); + await nextUpdate(customField); + expect(customField.value).to.equal(''); + }); }); describe('value set with attribute', () => {