@vaadin/vaadin-combo-box 5.4.10 → 5.4.11

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.10",
13
+ "version": "5.4.11",
14
14
  "main": "vaadin-combo-box.js",
15
15
  "author": "Vaadin Ltd",
16
16
  "license": "Apache-2.0",
@@ -33,31 +33,31 @@
33
33
  "type-detect": "1.0.0"
34
34
  },
35
35
  "dependencies": {
36
- "@polymer/iron-a11y-keys-behavior": "^3.0.0",
37
36
  "@polymer/iron-a11y-announcer": "^3.0.0",
37
+ "@polymer/iron-a11y-keys-behavior": "^3.0.0",
38
38
  "@polymer/iron-list": "^3.0.0",
39
39
  "@polymer/iron-resizable-behavior": "^3.0.0",
40
40
  "@polymer/polymer": "^3.0.0",
41
41
  "@vaadin/vaadin-control-state-mixin": "^2.2.2",
42
- "@vaadin/vaadin-overlay": "^3.5.0",
43
- "@vaadin/vaadin-text-field": "^2.8.0",
44
- "@vaadin/vaadin-themable-mixin": "^1.6.1",
42
+ "@vaadin/vaadin-element-mixin": "^2.4.1",
43
+ "@vaadin/vaadin-item": "^2.3.0",
45
44
  "@vaadin/vaadin-lumo-styles": "^1.1.1",
46
45
  "@vaadin/vaadin-material-styles": "^1.1.2",
47
- "@vaadin/vaadin-item": "^2.3.0",
48
- "@vaadin/vaadin-element-mixin": "^2.4.1"
46
+ "@vaadin/vaadin-overlay": "^3.5.0",
47
+ "@vaadin/vaadin-text-field": "^2.8.0",
48
+ "@vaadin/vaadin-themable-mixin": "^1.6.1"
49
49
  },
50
50
  "scripts": {
51
- "generate-typings": "gen-typescript-declarations --outDir . --verify"
52
- },
53
- "devDependencies": {
54
- "@polymer/iron-form": "^3.0.0",
51
+ "generate-typings": "gen-typescript-declarations --outDir . --verify"
52
+ },
53
+ "devDependencies": {
55
54
  "@polymer/iron-component-page": "^4.0.0",
55
+ "@polymer/iron-form": "^3.0.0",
56
56
  "@polymer/iron-test-helpers": "^3.0.0",
57
57
  "@polymer/paper-input": "^3.0.0",
58
58
  "@vaadin/vaadin-button": "^2.4.0",
59
- "wct-browser-legacy": "^1.0.1",
60
59
  "@vaadin/vaadin-demo-helpers": "^3.1.0",
61
- "@vaadin/vaadin-dialog": "^2.5.0"
60
+ "@vaadin/vaadin-dialog": "^2.5.0",
61
+ "wct-browser-legacy": "^1.0.1"
62
62
  }
63
63
  }
@@ -44,6 +44,17 @@ class ComboBoxOverlayElement extends OverlayElement {
44
44
  return 'vaadin-combo-box-overlay';
45
45
  }
46
46
 
47
+ static get properties() {
48
+ return {
49
+ /**
50
+ * The element to position/align the dropdown by.
51
+ */
52
+ positionTarget: {
53
+ type: Object
54
+ }
55
+ };
56
+ }
57
+
47
58
  static get template() {
48
59
  if (!memoizedTemplate) {
49
60
  memoizedTemplate = super.template.cloneNode(true);
@@ -72,6 +83,19 @@ class ComboBoxOverlayElement extends OverlayElement {
72
83
  const content = this.shadowRoot.querySelector('[part~="content"]');
73
84
  content.parentNode.insertBefore(loader, content);
74
85
  }
86
+
87
+ /**
88
+ * Override OverlayElement._outsideClickListener to prevent closing the
89
+ * overlay when clicking into the combo box input element
90
+ * @param event
91
+ * @private
92
+ */
93
+ _outsideClickListener(event) {
94
+ const eventPath = event.composedPath();
95
+ if (eventPath.indexOf(this.positionTarget) < 0 && eventPath.indexOf(this) < 0) {
96
+ this.close();
97
+ }
98
+ }
75
99
  }
76
100
 
77
101
  customElements.define(ComboBoxOverlayElement.is, ComboBoxOverlayElement);
@@ -95,7 +119,7 @@ class ComboBoxDropdownElement extends DisableUpgradeMixin(
95
119
  display: none;
96
120
  }
97
121
  </style>
98
- <vaadin-combo-box-overlay id="overlay" hidden\$="[[hidden]]" opened="[[opened]]" template="{{template}}" style="align-items: stretch; margin: 0;" theme\$="[[theme]]">
122
+ <vaadin-combo-box-overlay id="overlay" hidden\$="[[hidden]]" position-target="[[positionTarget]]" opened="{{opened}}" template="{{template}}" style="align-items: stretch; margin: 0;" theme\$="[[theme]]">
99
123
  <slot></slot>
100
124
  </vaadin-combo-box-overlay>
101
125
  `;
@@ -142,7 +166,6 @@ class ComboBoxDropdownElement extends DisableUpgradeMixin(
142
166
  constructor() {
143
167
  super();
144
168
  this._boundSetPosition = this._setPosition.bind(this);
145
- this._boundOutsideClickListener = this._outsideClickListener.bind(this);
146
169
  }
147
170
 
148
171
  connectedCallback() {
@@ -198,26 +221,13 @@ class ComboBoxDropdownElement extends DisableUpgradeMixin(
198
221
  this._setPosition();
199
222
 
200
223
  window.addEventListener('scroll', this._boundSetPosition, true);
201
- document.addEventListener('click', this._boundOutsideClickListener, true);
202
224
  this.dispatchEvent(new CustomEvent('vaadin-combo-box-dropdown-opened', {bubbles: true, composed: true}));
203
225
  } else if (!this.__emptyItems) {
204
226
  window.removeEventListener('scroll', this._boundSetPosition, true);
205
- document.removeEventListener('click', this._boundOutsideClickListener, true);
206
227
  this.dispatchEvent(new CustomEvent('vaadin-combo-box-dropdown-closed', {bubbles: true, composed: true}));
207
228
  }
208
229
  }
209
230
 
210
-
211
- // We need to listen on 'click' event and capture it and close the overlay before
212
- // propagating the event to the listener in the button. Otherwise, if the clicked button would call
213
- // open(), this would happen: https://www.youtube.com/watch?v=Z86V_ICUCD4
214
- _outsideClickListener(event) {
215
- const eventPath = event.composedPath();
216
- if (eventPath.indexOf(this.positionTarget) < 0 && eventPath.indexOf(this.$.overlay) < 0) {
217
- this.opened = false;
218
- }
219
- }
220
-
221
231
  _isPositionFixed(element) {
222
232
  const offsetParent = this._getOffsetParent(element);
223
233
 
@@ -229,7 +229,7 @@ class ComboBoxElement extends
229
229
  }
230
230
 
231
231
  static get version() {
232
- return '5.4.10';
232
+ return '5.4.11';
233
233
  }
234
234
 
235
235
  static get properties() {