@vaadin/combo-box 23.1.2 → 23.1.5

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.2",
3
+ "version": "23.1.5",
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.2",
40
- "@vaadin/field-base": "^23.1.2",
41
- "@vaadin/input-container": "^23.1.2",
42
- "@vaadin/item": "^23.1.2",
43
- "@vaadin/lit-renderer": "^23.1.2",
44
- "@vaadin/vaadin-lumo-styles": "^23.1.2",
45
- "@vaadin/vaadin-material-styles": "^23.1.2",
46
- "@vaadin/vaadin-overlay": "^23.1.2",
47
- "@vaadin/vaadin-themable-mixin": "^23.1.2"
39
+ "@vaadin/component-base": "^23.1.5",
40
+ "@vaadin/field-base": "^23.1.5",
41
+ "@vaadin/input-container": "^23.1.5",
42
+ "@vaadin/item": "^23.1.5",
43
+ "@vaadin/lit-renderer": "^23.1.5",
44
+ "@vaadin/vaadin-lumo-styles": "^23.1.5",
45
+ "@vaadin/vaadin-material-styles": "^23.1.5",
46
+ "@vaadin/vaadin-overlay": "^23.1.5",
47
+ "@vaadin/vaadin-themable-mixin": "^23.1.5"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@esm-bundle/chai": "^4.3.4",
51
- "@vaadin/polymer-legacy-adapter": "^23.1.2",
51
+ "@vaadin/polymer-legacy-adapter": "^23.1.5",
52
52
  "@vaadin/testing-helpers": "^0.3.2",
53
- "@vaadin/text-field": "^23.1.2",
53
+ "@vaadin/text-field": "^23.1.5",
54
54
  "lit": "^2.0.0",
55
55
  "sinon": "^13.0.2"
56
56
  },
57
- "gitHead": "6fb205c6e9a761feadfb779dd5d7af96d3102e56"
57
+ "gitHead": "326938919a54353231af25d341ba6076c249afee"
58
58
  }
@@ -20,7 +20,7 @@ export type ComboBoxDataProvider<TItem> = (
20
20
 
21
21
  export declare function ComboBoxDataProviderMixin<TItem, T extends Constructor<HTMLElement>>(
22
22
  base: T,
23
- ): T & Constructor<ComboBoxDataProviderMixinClass<TItem>>;
23
+ ): Constructor<ComboBoxDataProviderMixinClass<TItem>> & T;
24
24
 
25
25
  export declare class ComboBoxDataProviderMixinClass<TItem> {
26
26
  /**
@@ -126,13 +126,13 @@ declare class ComboBoxLight<TItem = ComboBoxDefaultItem> extends HTMLElement {
126
126
  addEventListener<K extends keyof ComboBoxLightEventMap<TItem>>(
127
127
  type: K,
128
128
  listener: (this: ComboBoxLight<TItem>, ev: ComboBoxLightEventMap<TItem>[K]) => void,
129
- options?: boolean | AddEventListenerOptions,
129
+ options?: AddEventListenerOptions | boolean,
130
130
  ): void;
131
131
 
132
132
  removeEventListener<K extends keyof ComboBoxLightEventMap<TItem>>(
133
133
  type: K,
134
134
  listener: (this: ComboBoxLight<TItem>, ev: ComboBoxLightEventMap<TItem>[K]) => void,
135
- options?: boolean | EventListenerOptions,
135
+ options?: EventListenerOptions | boolean,
136
136
  ): void;
137
137
  }
138
138
 
@@ -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 (
@@ -24,11 +24,11 @@ export type ComboBoxRenderer<TItem> = (
24
24
 
25
25
  export declare function ComboBoxMixin<TItem, T extends Constructor<HTMLElement>>(
26
26
  base: T,
27
- ): T &
28
- Constructor<ComboBoxMixinClass<TItem>> &
27
+ ): Constructor<ComboBoxMixinClass<TItem>> &
29
28
  Constructor<DisabledMixinClass> &
30
29
  Constructor<InputMixinClass> &
31
- Constructor<KeyboardMixinClass>;
30
+ Constructor<KeyboardMixinClass> &
31
+ T;
32
32
 
33
33
  export declare class ComboBoxMixinClass<TItem> {
34
34
  /**
@@ -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();
@@ -212,13 +212,13 @@ declare class ComboBox<TItem = ComboBoxDefaultItem> extends HTMLElement {
212
212
  addEventListener<K extends keyof ComboBoxEventMap<TItem>>(
213
213
  type: K,
214
214
  listener: (this: ComboBox<TItem>, ev: ComboBoxEventMap<TItem>[K]) => void,
215
- options?: boolean | AddEventListenerOptions,
215
+ options?: AddEventListenerOptions | boolean,
216
216
  ): void;
217
217
 
218
218
  removeEventListener<K extends keyof ComboBoxEventMap<TItem>>(
219
219
  type: K,
220
220
  listener: (this: ComboBox<TItem>, ev: ComboBoxEventMap<TItem>[K]) => void,
221
- options?: boolean | EventListenerOptions,
221
+ options?: EventListenerOptions | boolean,
222
222
  ): void;
223
223
  }
224
224