@vaadin/virtual-list 23.5.7 → 23.5.9

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/virtual-list",
3
- "version": "23.5.7",
3
+ "version": "23.5.9",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -38,15 +38,15 @@
38
38
  ],
39
39
  "dependencies": {
40
40
  "@polymer/polymer": "^3.0.0",
41
- "@vaadin/component-base": "~23.5.7",
42
- "@vaadin/lit-renderer": "~23.5.7",
43
- "@vaadin/vaadin-lumo-styles": "~23.5.7",
44
- "@vaadin/vaadin-material-styles": "~23.5.7",
45
- "@vaadin/vaadin-themable-mixin": "~23.5.7"
41
+ "@vaadin/component-base": "~23.5.9",
42
+ "@vaadin/lit-renderer": "~23.5.9",
43
+ "@vaadin/vaadin-lumo-styles": "~23.5.9",
44
+ "@vaadin/vaadin-material-styles": "~23.5.9",
45
+ "@vaadin/vaadin-themable-mixin": "~23.5.9"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@esm-bundle/chai": "^4.3.4",
49
- "@vaadin/polymer-legacy-adapter": "~23.5.7",
49
+ "@vaadin/polymer-legacy-adapter": "~23.5.9",
50
50
  "@vaadin/testing-helpers": "^0.3.2",
51
51
  "lit": "^2.0.0",
52
52
  "sinon": "^13.0.2"
@@ -55,5 +55,5 @@
55
55
  "web-types.json",
56
56
  "web-types.lit.json"
57
57
  ],
58
- "gitHead": "19efa292d13bc1052f0d2c15b19ebc2ebd3dc156"
58
+ "gitHead": "42b9cb7f53bf56753c61d7373c76081ba46bff38"
59
59
  }
@@ -110,6 +110,11 @@ class VirtualList extends ElementMixin(ControllerMixin(ThemableMixin(PolymerElem
110
110
  return ['__itemsOrRendererChanged(items, renderer, __virtualizer)'];
111
111
  }
112
112
 
113
+ constructor() {
114
+ super();
115
+ this.__onDragStart = this.__onDragStart.bind(this);
116
+ }
117
+
113
118
  /** @protected */
114
119
  ready() {
115
120
  super.ready();
@@ -128,6 +133,22 @@ class VirtualList extends ElementMixin(ControllerMixin(ThemableMixin(PolymerElem
128
133
  processTemplates(this);
129
134
  }
130
135
 
136
+ /** @protected */
137
+ connectedCallback() {
138
+ super.connectedCallback();
139
+ // Chromium based browsers cannot properly generate drag images for elements
140
+ // that have children with massive heights. This workaround prevents crashes
141
+ // and performance issues by excluding the items from the drag image.
142
+ // https://github.com/vaadin/web-components/issues/7985
143
+ document.addEventListener('dragstart', this.__onDragStart, { capture: true });
144
+ }
145
+
146
+ /** @protected */
147
+ disconnectedCallback() {
148
+ super.disconnectedCallback();
149
+ document.removeEventListener('dragstart', this.__onDragStart, { capture: true });
150
+ }
151
+
131
152
  /**
132
153
  * Scroll to a specific index in the virtual list.
133
154
  *
@@ -179,6 +200,29 @@ class VirtualList extends ElementMixin(ControllerMixin(ThemableMixin(PolymerElem
179
200
  }
180
201
  }
181
202
 
203
+ /** @private */
204
+ __onDragStart(e) {
205
+ // The dragged element can be the element itself or a parent of the element
206
+ if (!e.target.contains(this)) {
207
+ return;
208
+ }
209
+ // The threshold value 20000 provides a buffer to both
210
+ // - avoid the crash and the performance issues
211
+ // - unnecessarily avoid excluding items from the drag image
212
+ if (this.$.items.offsetHeight > 20000) {
213
+ const initialItemsMaxHeight = this.$.items.style.maxHeight;
214
+ const initialVirtualListOverflow = this.style.overflow;
215
+ // Momentarily hides the items until the browser starts generating the
216
+ // drag image.
217
+ this.$.items.style.maxHeight = '0';
218
+ this.style.overflow = 'hidden';
219
+ requestAnimationFrame(() => {
220
+ this.$.items.style.maxHeight = initialItemsMaxHeight;
221
+ this.style.overflow = initialVirtualListOverflow;
222
+ });
223
+ }
224
+ }
225
+
182
226
  /**
183
227
  * Gets the index of the first visible item in the viewport.
184
228
  *
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/virtual-list",
4
- "version": "23.5.7",
4
+ "version": "23.5.9",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/virtual-list",
4
- "version": "23.5.7",
4
+ "version": "23.5.9",
5
5
  "description-markup": "markdown",
6
6
  "framework": "lit",
7
7
  "framework-config": {