Skip to content

Commit 6d98ec0

Browse files
paodbjavier-godoy
authored andcommitted
fix: preserve typed value if it does not match a valid item on enter
1 parent ecbdfc3 commit 6d98ec0

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/main/resources/META-INF/frontend/paper-chip-input-autocomplete.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -329,12 +329,14 @@ class PaperChipInputAutocomplete extends ThemableMixin(PolymerElement) {
329329
}
330330

331331
_onKeyEnter() {
332-
if (this.additionalItems || (this._inputValue != '' && this._inputValue != undefined)) {
333-
this._saveTag(this._inputValue);
334-
this.required = false;
335-
this.autoValidate = false;
336-
this._inputValue = '';
337-
}
332+
if(this._inputValue != '' && this._inputValue != undefined){
333+
if(this.additionalItems || (this._filteredSource && this._filteredSource.length == 1 && this._filteredSource[0].value == this._inputValue)){
334+
this._saveTag(this._inputValue);
335+
this.required = false;
336+
this.autoValidate = false;
337+
this._inputValue = '';
338+
}
339+
}
338340
}
339341

340342
_onKeyBackspace(event) {

0 commit comments

Comments
 (0)