Skip to content

Commit

Permalink
Never modify value if there is no item meeting it. Fixes #130 #136
Browse files Browse the repository at this point in the history
  • Loading branch information
manolo committed Jun 27, 2018
1 parent 635c9fd commit 810a1bf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/vaadin-dropdown-menu.html
Expand Up @@ -434,9 +434,9 @@

this._attachSelectedItem(selected);

if (!this._valueChanging) {
if (!this._valueChanging && selected) {
this._selectedChanging = true;
this.value = selected && selected.value || '';
this.value = selected.value || '';
delete this._selectedChanging;
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/dropdown-menu-test.html
Expand Up @@ -353,10 +353,10 @@
expect(menu.selected).to.be.equal(1);
});

it('Should select first item with empty value when when value is not found in items', () => {
it('Should not select any item when value is not found in items', () => {
dropdown.value = 'v2';
dropdown.value = 'foo';
expect(menu.selected).to.be.equal(0);
expect(menu.selected).to.be.undefined;
});

describe('has-value attribute on text-field', () => {
Expand Down

0 comments on commit 810a1bf

Please sign in to comment.