@vaadin/combo-box 23.1.3 → 23.1.6

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/combo-box",
3
- "version": "23.1.3",
3
+ "version": "23.1.6",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -36,23 +36,23 @@
36
36
  "dependencies": {
37
37
  "@open-wc/dedupe-mixin": "^1.3.0",
38
38
  "@polymer/polymer": "^3.0.0",
39
- "@vaadin/component-base": "^23.1.3",
40
- "@vaadin/field-base": "^23.1.3",
41
- "@vaadin/input-container": "^23.1.3",
42
- "@vaadin/item": "^23.1.3",
43
- "@vaadin/lit-renderer": "^23.1.3",
44
- "@vaadin/vaadin-lumo-styles": "^23.1.3",
45
- "@vaadin/vaadin-material-styles": "^23.1.3",
46
- "@vaadin/vaadin-overlay": "^23.1.3",
47
- "@vaadin/vaadin-themable-mixin": "^23.1.3"
39
+ "@vaadin/component-base": "^23.1.6",
40
+ "@vaadin/field-base": "^23.1.6",
41
+ "@vaadin/input-container": "^23.1.6",
42
+ "@vaadin/item": "^23.1.6",
43
+ "@vaadin/lit-renderer": "^23.1.6",
44
+ "@vaadin/vaadin-lumo-styles": "^23.1.6",
45
+ "@vaadin/vaadin-material-styles": "^23.1.6",
46
+ "@vaadin/vaadin-overlay": "^23.1.6",
47
+ "@vaadin/vaadin-themable-mixin": "^23.1.6"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@esm-bundle/chai": "^4.3.4",
51
- "@vaadin/polymer-legacy-adapter": "^23.1.3",
51
+ "@vaadin/polymer-legacy-adapter": "^23.1.6",
52
52
  "@vaadin/testing-helpers": "^0.3.2",
53
- "@vaadin/text-field": "^23.1.3",
53
+ "@vaadin/text-field": "^23.1.6",
54
54
  "lit": "^2.0.0",
55
55
  "sinon": "^13.0.2"
56
56
  },
57
- "gitHead": "3066c296ad0ef652bc49417005523398199f1bf2"
57
+ "gitHead": "b356bcba208f6569d3d85ac11795c3e736adce85"
58
58
  }
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import './vaadin-combo-box-dropdown.js';
7
7
  import { dashToCamelCase } from '@polymer/polymer/lib/utils/case-map.js';
8
+ import { afterNextRender } from '@polymer/polymer/lib/utils/render-status.js';
8
9
  import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
9
10
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
10
11
  import { ComboBoxDataProviderMixin } from './vaadin-combo-box-data-provider-mixin.js';
@@ -118,14 +119,14 @@ class ComboBoxLight extends ComboBoxDataProviderMixin(ComboBoxMixin(ThemableMixi
118
119
  /** @protected */
119
120
  ready() {
120
121
  super.ready();
122
+
121
123
  this._toggleElement = this.querySelector('.toggle-button');
122
- }
123
124
 
124
- /** @protected */
125
- connectedCallback() {
126
- super.connectedCallback();
127
- this._setInputElement(this.querySelector('vaadin-text-field,.input'));
128
- this._revertInputValue();
125
+ // Wait until the slotted input DOM is ready
126
+ afterNextRender(this, () => {
127
+ this._setInputElement(this.querySelector('vaadin-text-field,.input'));
128
+ this._revertInputValue();
129
+ });
129
130
  }
130
131
 
131
132
  /**
@@ -147,6 +148,38 @@ class ComboBoxLight extends ComboBoxDataProviderMixin(ComboBoxMixin(ThemableMixi
147
148
  return dashToCamelCase(this.attrForValue);
148
149
  }
149
150
 
151
+ /**
152
+ * @protected
153
+ * @override
154
+ * @return {HTMLInputElement | undefined}
155
+ */
156
+ get _nativeInput() {
157
+ const input = this.inputElement;
158
+
159
+ if (input) {
160
+ // Support `<input class="input">`
161
+ if (input instanceof HTMLInputElement) {
162
+ return input;
163
+ }
164
+
165
+ // Support `<input>` in light DOM (e.g. `vaadin-text-field`)
166
+ const slottedInput = input.querySelector('input');
167
+ if (slottedInput) {
168
+ return slottedInput;
169
+ }
170
+
171
+ if (input.shadowRoot) {
172
+ // Support `<input>` in Shadow DOM (e.g. `mwc-textfield`)
173
+ const shadowInput = input.shadowRoot.querySelector('input');
174
+ if (shadowInput) {
175
+ return shadowInput;
176
+ }
177
+ }
178
+ }
179
+
180
+ return undefined;
181
+ }
182
+
150
183
  /** @protected */
151
184
  _isClearButton(event) {
152
185
  return (
@@ -238,14 +238,26 @@ export const ComboBoxMixin = (subclass) =>
238
238
  }
239
239
  }
240
240
 
241
+ /**
242
+ * Get a reference to the native `<input>` element.
243
+ * Override to provide a custom input.
244
+ * @protected
245
+ * @return {HTMLInputElement | undefined}
246
+ */
247
+ get _nativeInput() {
248
+ return this.inputElement;
249
+ }
250
+
241
251
  /**
242
252
  * Override method inherited from `InputMixin`
243
253
  * to customize the input element.
244
254
  * @protected
245
255
  * @override
246
256
  */
247
- _inputElementChanged(input) {
248
- super._inputElementChanged(input);
257
+ _inputElementChanged(inputElement) {
258
+ super._inputElementChanged(inputElement);
259
+
260
+ const input = this._nativeInput;
249
261
 
250
262
  if (input) {
251
263
  input.autocomplete = 'off';
@@ -346,7 +358,7 @@ export const ComboBoxMixin = (subclass) =>
346
358
 
347
359
  /** @private */
348
360
  _updateActiveDescendant(index) {
349
- const input = this.inputElement;
361
+ const input = this._nativeInput;
350
362
  if (!input) {
351
363
  return;
352
364
  }
@@ -382,7 +394,7 @@ export const ComboBoxMixin = (subclass) =>
382
394
  }
383
395
  }
384
396
 
385
- const input = this.inputElement;
397
+ const input = this._nativeInput;
386
398
  if (input) {
387
399
  input.setAttribute('aria-expanded', !!opened);
388
400
 
@@ -1094,6 +1106,12 @@ export const ComboBoxMixin = (subclass) =>
1094
1106
 
1095
1107
  /** @private */
1096
1108
  _onFocusout(event) {
1109
+ // VoiceOver on iOS fires `focusout` event when moving focus to the item in the dropdown.
1110
+ // Do not focus the input in this case, because it would break announcement for the item.
1111
+ if (event.relatedTarget && this._getItemElements().includes(event.relatedTarget)) {
1112
+ return;
1113
+ }
1114
+
1097
1115
  // Fixes the problem with `focusout` happening when clicking on the scroll bar on Edge
1098
1116
  if (event.relatedTarget === this.$.dropdown.$.overlay) {
1099
1117
  event.composedPath()[0].focus();