Skip to content

Commit

Permalink
Fix user input (#480)
Browse files Browse the repository at this point in the history
* Add test for user input without value change

* Do not set userInput if there is no change

* Remove flag where it was added
  • Loading branch information
yuriy-fix authored and tomivirkki committed Jun 12, 2020
1 parent feb80ac commit e6a1ff4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/vaadin-text-field-mixin.html
Expand Up @@ -410,7 +410,9 @@
if (!e.__fromClearButton) {
this.__userInput = true;
}

this.value = e.target.value;
this.__userInput = false;
}

// NOTE(yuriy): Workaround needed for IE11 and Edge for proper displaying
Expand Down Expand Up @@ -467,7 +469,6 @@
}

if (this.__userInput) {
this.__userInput = false;
return;
} else if (newVal !== undefined) {
this.inputElement.value = newVal;
Expand Down
20 changes: 20 additions & 0 deletions test/text-field.html
Expand Up @@ -439,6 +439,26 @@

});

describe('value property', function() {
let textField, input;

beforeEach(function() {
textField = fixture(`default${fixtureName}`);
input = textField.inputElement;
});

it('should not consider updating the value as user input if the value is not changed', () => {
const event = new Event('input', {
bubbles: true,
cancelable: true
});
input.dispatchEvent(event);

textField.value = 'foo';
expect(input.value).to.equal('foo');
});
});

describe(`events ${condition}`, function() {
let textField, input;

Expand Down

0 comments on commit e6a1ff4

Please sign in to comment.