@vaadin/combo-box 23.1.0-beta3 → 23.1.0-rc2

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.0-beta3",
3
+ "version": "23.1.0-rc2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -36,24 +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.0-beta3",
40
- "@vaadin/field-base": "23.1.0-beta3",
41
- "@vaadin/input-container": "23.1.0-beta3",
42
- "@vaadin/item": "23.1.0-beta3",
43
- "@vaadin/lit-renderer": "23.1.0-beta3",
44
- "@vaadin/vaadin-lumo-styles": "23.1.0-beta3",
45
- "@vaadin/vaadin-material-styles": "23.1.0-beta3",
46
- "@vaadin/vaadin-overlay": "23.1.0-beta3",
47
- "@vaadin/vaadin-themable-mixin": "23.1.0-beta3"
39
+ "@vaadin/component-base": "23.1.0-rc2",
40
+ "@vaadin/field-base": "23.1.0-rc2",
41
+ "@vaadin/input-container": "23.1.0-rc2",
42
+ "@vaadin/item": "23.1.0-rc2",
43
+ "@vaadin/lit-renderer": "23.1.0-rc2",
44
+ "@vaadin/vaadin-lumo-styles": "23.1.0-rc2",
45
+ "@vaadin/vaadin-material-styles": "23.1.0-rc2",
46
+ "@vaadin/vaadin-overlay": "23.1.0-rc2",
47
+ "@vaadin/vaadin-themable-mixin": "23.1.0-rc2"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@esm-bundle/chai": "^4.3.4",
51
- "@vaadin/dialog": "23.1.0-beta3",
52
- "@vaadin/polymer-legacy-adapter": "23.1.0-beta3",
51
+ "@vaadin/polymer-legacy-adapter": "23.1.0-rc2",
53
52
  "@vaadin/testing-helpers": "^0.3.2",
54
- "@vaadin/text-field": "23.1.0-beta3",
53
+ "@vaadin/text-field": "23.1.0-rc2",
55
54
  "lit": "^2.0.0",
56
55
  "sinon": "^13.0.2"
57
56
  },
58
- "gitHead": "c787ceb8a312f88631c6d429ff320d5f89b1b838"
57
+ "gitHead": "154c6782c42145fed21e443559fbe2d781ad3ec7"
59
58
  }
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import { Constructor } from '@open-wc/dedupe-mixin';
7
7
 
8
- export type ComboBoxDataProviderCallback<TItem> = (items: Array<TItem>, size: number) => void;
8
+ export type ComboBoxDataProviderCallback<TItem> = (items: TItem[], size: number) => void;
9
9
 
10
10
  export interface ComboBoxDataProviderParams {
11
11
  page: number;
@@ -74,18 +74,6 @@ export const ComboBoxDataProviderMixin = (superClass) =>
74
74
  ];
75
75
  }
76
76
 
77
- /** @private */
78
- _dataProviderClearFilter(dataProvider, opened, value) {
79
- // Can't depend on filter in this observer as we don't want
80
- // to clear the filter whenever it's set
81
- if (dataProvider && !this.loading && this.filter && !(opened && this.autoOpenDisabled && value === this.filter)) {
82
- this.size = undefined;
83
- this._pendingRequests = {};
84
- this.filter = '';
85
- this.clearCache();
86
- }
87
- }
88
-
89
77
  /** @protected */
90
78
  ready() {
91
79
  super.ready();
@@ -118,8 +106,32 @@ export const ComboBoxDataProviderMixin = (superClass) =>
118
106
  return;
119
107
  }
120
108
 
109
+ this._refreshData();
110
+ }
111
+
112
+ /** @private */
113
+ _dataProviderClearFilter(dataProvider, opened, value) {
114
+ // Can't depend on filter in this observer as we don't want
115
+ // to clear the filter whenever it's set
116
+ if (dataProvider && !this.loading && this.filter && !(opened && this.autoOpenDisabled && value === this.filter)) {
117
+ this._refreshData(true);
118
+ }
119
+ }
120
+
121
+ /** @private */
122
+ _refreshData(clearFilter) {
123
+ // Immediately mark as loading if this refresh leads to re-fetching pages
124
+ // This prevents some issues with the properties below triggering
125
+ // observers that also rely on the loading state
126
+ this.loading = this._shouldFetchData();
127
+ // Reset size and internal loading state
121
128
  this.size = undefined;
122
129
  this._pendingRequests = {};
130
+ // Clear filter if requested
131
+ if (clearFilter) {
132
+ this.filter = '';
133
+ }
134
+ // Clear cached pages, and reload current page if we need the data
123
135
  this.clearCache();
124
136
  }
125
137
 
@@ -31,14 +31,6 @@ export declare function ComboBoxMixin<TItem, T extends Constructor<HTMLElement>>
31
31
  Constructor<KeyboardMixinClass>;
32
32
 
33
33
  export declare class ComboBoxMixinClass<TItem> {
34
- protected readonly _propertyForValue: string;
35
-
36
- protected _inputElementValue: string | undefined;
37
-
38
- protected _revertInputValue(): void;
39
-
40
- protected _getItemElements(): HTMLElement[];
41
-
42
34
  /**
43
35
  * True if the dropdown is open, false otherwise.
44
36
  */
@@ -72,7 +64,7 @@ export declare class ComboBoxMixinClass<TItem> {
72
64
  * A full set of items to filter the visible options from.
73
65
  * The items can be of either `String` or `Object` type.
74
66
  */
75
- items: Array<TItem> | undefined;
67
+ items: TItem[] | undefined;
76
68
 
77
69
  /**
78
70
  * If `true`, the user can input a value that is not present in the items list.
@@ -88,7 +80,7 @@ export declare class ComboBoxMixinClass<TItem> {
88
80
  * can be assigned directly to omit the internal filtering functionality.
89
81
  * The items can be of either `String` or `Object` type.
90
82
  */
91
- filteredItems: Array<TItem> | undefined;
83
+ filteredItems: TItem[] | undefined;
92
84
 
93
85
  /**
94
86
  * The `String` value for the selected item of the combo box.
@@ -151,6 +143,10 @@ export declare class ComboBoxMixinClass<TItem> {
151
143
  */
152
144
  invalid: boolean;
153
145
 
146
+ protected readonly _propertyForValue: string;
147
+
148
+ protected _inputElementValue: string | undefined;
149
+
154
150
  /**
155
151
  * Requests an update for the content of items.
156
152
  * While performing the update, it invokes the renderer (passed in the `renderer` property) once an item.
@@ -179,4 +175,8 @@ export declare class ComboBoxMixinClass<TItem> {
179
175
  * You can override this method for custom validations.
180
176
  */
181
177
  checkValidity(): boolean;
178
+
179
+ protected _revertInputValue(): void;
180
+
181
+ protected _getItemElements(): HTMLElement[];
182
182
  }
@@ -971,19 +971,15 @@ export const ComboBoxMixin = (subclass) =>
971
971
  this._selectItemForValue(this.value);
972
972
  }
973
973
 
974
- // Do not update `_focusedIndex` to from `-1` to old value during scroll.
975
- // Otherwise, the scroll would jump back to the previously focused item.
976
- if (!this.loading) {
977
- const inputValue = this._inputElementValue;
978
- if (inputValue === undefined || inputValue === this._getItemLabel(this.selectedItem)) {
979
- // When the input element value is the same as the current value or not defined,
980
- // set the focused index to the item that matches the value.
981
- this._focusedIndex = this.$.dropdown.indexOfLabel(this._getItemLabel(this.selectedItem));
982
- } else {
983
- // When the user filled in something that is different from the current value = filtering is enabled,
984
- // set the focused index to the item that matches the filter query.
985
- this._focusedIndex = this.$.dropdown.indexOfLabel(this.filter);
986
- }
974
+ const inputValue = this._inputElementValue;
975
+ if (inputValue === undefined || inputValue === this._getItemLabel(this.selectedItem)) {
976
+ // When the input element value is the same as the current value or not defined,
977
+ // set the focused index to the item that matches the value.
978
+ this._focusedIndex = this.$.dropdown.indexOfLabel(this._getItemLabel(this.selectedItem));
979
+ } else {
980
+ // When the user filled in something that is different from the current value = filtering is enabled,
981
+ // set the focused index to the item that matches the filter query.
982
+ this._focusedIndex = this.$.dropdown.indexOfLabel(this.filter);
987
983
  }
988
984
  }
989
985
  }
@@ -259,7 +259,9 @@ export class ComboBoxScroller extends PolymerElement {
259
259
  this.requestContentUpdate();
260
260
  }
261
261
 
262
- if (index >= 0) {
262
+ // Do not jump back to the previously focused item while loading
263
+ // when requesting next page from the data provider on scroll.
264
+ if (index >= 0 && !this.loading) {
263
265
  this.scrollIntoView(index);
264
266
  }
265
267
  }
@@ -1,4 +1,5 @@
1
1
  import '@vaadin/vaadin-material-styles/color.js';
2
+ import '@vaadin/vaadin-overlay/theme/material/vaadin-overlay.js';
2
3
  import { menuOverlay } from '@vaadin/vaadin-material-styles/mixins/menu-overlay.js';
3
4
  import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
4
5