@vaadin/component-base 24.6.4 → 24.6.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/component-base",
3
- "version": "24.6.4",
3
+ "version": "24.6.5",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -38,10 +38,10 @@
38
38
  "lit": "^3.0.0"
39
39
  },
40
40
  "devDependencies": {
41
- "@vaadin/chai-plugins": "~24.6.4",
42
- "@vaadin/test-runner-commands": "~24.6.4",
41
+ "@vaadin/chai-plugins": "~24.6.5",
42
+ "@vaadin/test-runner-commands": "~24.6.5",
43
43
  "@vaadin/testing-helpers": "^1.1.0",
44
44
  "sinon": "^18.0.0"
45
45
  },
46
- "gitHead": "02d8ac2c39bc2d27fe60acec7d7bac6bdb73d8a1"
46
+ "gitHead": "fc109a4234a1f60e89717ab1c0dc8fb4451aa418"
47
47
  }
package/src/define.js CHANGED
@@ -13,7 +13,7 @@ function dashToCamelCase(dash) {
13
13
 
14
14
  const experimentalMap = {};
15
15
 
16
- export function defineCustomElement(CustomElement, version = '24.6.4') {
16
+ export function defineCustomElement(CustomElement, version = '24.6.5') {
17
17
  Object.defineProperty(CustomElement, 'version', {
18
18
  get() {
19
19
  return version;
@@ -52,6 +52,20 @@ export class IronListAdapter {
52
52
  this.__resizeObserver.observe(this.scrollTarget);
53
53
  this.scrollTarget.addEventListener('scroll', () => this._scrollHandler());
54
54
 
55
+ const attachObserver = new ResizeObserver(([{ contentRect }]) => {
56
+ const isHidden = contentRect.width === 0 && contentRect.height === 0;
57
+ if (!isHidden && this.__scrollTargetHidden && this.scrollTarget.scrollTop !== this._scrollPosition) {
58
+ // When removing element from DOM, its scroll position is lost and
59
+ // virtualizer doesn't re-render when adding it to the DOM again.
60
+ // Restore scroll position when the scroll target becomes visible,
61
+ // which is the case e.g. when virtualizer is used inside a dialog.
62
+ this.scrollTarget.scrollTop = this._scrollPosition;
63
+ }
64
+
65
+ this.__scrollTargetHidden = isHidden;
66
+ });
67
+ attachObserver.observe(this.scrollTarget);
68
+
55
69
  this._scrollLineHeight = this._getScrollLineHeight();
56
70
  this.scrollTarget.addEventListener('wheel', (e) => this.__onWheel(e));
57
71