@itrocks/autocomplete 0.1.7 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/autocomplete.js +11 -1
  2. package/package.json +1 -1
package/autocomplete.js CHANGED
@@ -197,6 +197,8 @@ export class AutoComplete {
197
197
  if (DEBUG)
198
198
  console.log('input.value =');
199
199
  this.input.value = '';
200
+ this.lastStart = '';
201
+ this.suggestions.removeList();
200
202
  this.onInputValueChange();
201
203
  this.autoIdInputValue();
202
204
  }
@@ -217,8 +219,16 @@ export class AutoComplete {
217
219
  onBlur(_event) {
218
220
  if (DEBUG)
219
221
  console.log('onBlur()');
222
+ const suggestion = this.suggestions.selected();
220
223
  this.suggestions.removeList();
221
- if (!this.options.allowNew && this.idInput && this.input.value && !this.idInput.value) {
224
+ if (suggestion
225
+ && this.idInput?.value
226
+ && (this.input.value !== suggestion.caption)
227
+ && (toInsensitive(this.input.value) === toInsensitive(suggestion.caption))) {
228
+ this.input.value = suggestion.caption;
229
+ this.onInputValueChange();
230
+ }
231
+ else if (!this.options.allowNew && this.idInput && this.input.value && !this.idInput.value) {
222
232
  this.input.value = '';
223
233
  this.onInputValueChange();
224
234
  this.autoIdInputValue();
package/package.json CHANGED
@@ -40,5 +40,5 @@
40
40
  },
41
41
  "type": "module",
42
42
  "types": "./autocomplete.d.ts",
43
- "version": "0.1.7"
43
+ "version": "0.1.9"
44
44
  }