fix(field): clear method reset modelValue

This commit is contained in:
Carlos Esteban 2020-04-01 13:37:14 +02:00 committed by Thomas Allmer
parent 5103289f99
commit cf13410026
2 changed files with 5 additions and 5 deletions

View file

@ -162,7 +162,7 @@ export class LionField extends FormControlMixin(
// invalid and dirty/touched states respectively // invalid and dirty/touched states respectively
super.clear(); super.clear();
} }
this.value = ''; // can't set null here, because IE11 treats it as a string this.modelValue = ''; // can't set null here, because IE11 treats it as a string
} }
_onChange() { _onChange() {

View file

@ -110,11 +110,11 @@ describe('<lion-field>', () => {
it('can be cleared which erases value, validation and interaction states', async () => { it('can be cleared which erases value, validation and interaction states', async () => {
const el = await fixture(html`<${tag} value="Some value from attribute">${inputSlot}</${tag}>`); const el = await fixture(html`<${tag} value="Some value from attribute">${inputSlot}</${tag}>`);
el.clear(); el.clear();
expect(el.value).to.equal(''); expect(el.modelValue).to.equal('');
el.value = 'Some value from property'; el.modelValue = 'Some value from property';
expect(el.value).to.equal('Some value from property'); expect(el.modelValue).to.equal('Some value from property');
el.clear(); el.clear();
expect(el.value).to.equal(''); expect(el.modelValue).to.equal('');
}); });
it('can be reset which restores original modelValue', async () => { it('can be reset which restores original modelValue', async () => {