Skip to content

Commit

Permalink
fix: clear value when removing the last input (#8270)
Browse files Browse the repository at this point in the history
Co-authored-by: Sergey Vinogradov <mr.vursen@gmail.com>
  • Loading branch information
ugur-vaadin and vursen authored Dec 5, 2024
1 parent 4f7958c commit e7a89b3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/custom-field/src/vaadin-custom-field-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@ export const CustomFieldMixin = (superClass) =>
/** @private */
__inputsChanged(inputs, oldInputs) {
if (inputs.length === 0) {
if (oldInputs && oldInputs.length > 0) {
this.__setValue();
}
return;
}

Expand Down
13 changes: 13 additions & 0 deletions packages/custom-field/test/custom-field.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit e7a89b3

Please sign in to comment.