@vaadin/vaadin-combo-box 5.4.9 → 5.4.10

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.
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "repository": "vaadin/vaadin-combo-box",
11
11
  "homepage": "https://vaadin.com/components",
12
12
  "name": "@vaadin/vaadin-combo-box",
13
- "version": "5.4.9",
13
+ "version": "5.4.10",
14
14
  "main": "vaadin-combo-box.js",
15
15
  "author": "Vaadin Ltd",
16
16
  "license": "Apache-2.0",
@@ -576,16 +576,36 @@ export const ComboBoxMixin = subclass => class VaadinComboBoxMixinElement extend
576
576
  */
577
577
  _onEscape(e) {
578
578
  if (this.autoOpenDisabled) {
579
- this._focusedIndex = -1;
580
- this.cancel();
581
- } else if (this.opened) {
582
- this._stopPropagation(e);
583
-
584
- if (this._focusedIndex > -1) {
579
+ // Auto-open is disabled
580
+ if (this.opened || (this.value !== this._inputElementValue && this._inputElementValue.length > 0)) {
581
+ // The overlay is open or
582
+ // the input value has changed but the change hasn't been committed, so cancel it.
583
+ this._stopPropagation(e);
585
584
  this._focusedIndex = -1;
586
- this._revertInputValue();
587
- } else {
588
585
  this.cancel();
586
+ } else if (this.clearButtonVisible && !this.opened && !!this.value) {
587
+ this._stopPropagation(e);
588
+ // The clear button is visible and the overlay is closed, so clear the value.
589
+ this._clear();
590
+ }
591
+ } else {
592
+ // Auto-open is enabled
593
+ if (this.opened) {
594
+ // The overlay is open
595
+ this._stopPropagation(e);
596
+
597
+ if (this._focusedIndex > -1) {
598
+ // An item is focused, revert the input to the filtered value
599
+ this._focusedIndex = -1;
600
+ this._revertInputValue();
601
+ } else {
602
+ // No item is focused, cancel the change and close the overlay
603
+ this.cancel();
604
+ }
605
+ } else if (this.clearButtonVisible && !!this.value) {
606
+ this._stopPropagation(e);
607
+ // The clear button is visible and the overlay is closed, so clear the value.
608
+ this._clear();
589
609
  }
590
610
  }
591
611
  }
@@ -229,7 +229,7 @@ class ComboBoxElement extends
229
229
  }
230
230
 
231
231
  static get version() {
232
- return '5.4.9';
232
+ return '5.4.10';
233
233
  }
234
234
 
235
235
  static get properties() {
@@ -358,12 +358,8 @@ class ComboBoxElement extends
358
358
  // Stop propagation of Esc in capturing phase so that
359
359
  // vaadin-text-field will not handle Esc as a shortcut
360
360
  // to clear the value.
361
- // We need to set this listener for "this.inputElement"
362
- // instead of just "this", otherwise keyboard navigation behaviour
363
- // breaks a bit on Safari and some related tests fail.
364
- this.inputElement.addEventListener('keydown', e => {
361
+ this.addEventListener('keydown', e => {
365
362
  if (this._isEventKey(e, 'esc')) {
366
- this._stopPropagation(e);
367
363
  // Trigger _onEscape method of vaadin-combo-box-mixin because
368
364
  // bubbling phase is not reached.
369
365
  this._onEscape(e);