Skip to content

Commit

Permalink
added patch for virtualizer height fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Diaan committed Dec 19, 2024
1 parent 56a6e02 commit 73879be
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 8 deletions.
54 changes: 54 additions & 0 deletions .yarn/patches/@lit-labs-virtualizer-npm-2.0.14-58a3230753.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
diff --git a/layouts/flow.js b/layouts/flow.js
index 77ea288c5525ac46221c709f9eb97d8f5da14aeb..ecbfd5a38085b0688b912790b4f86f1fdf8798db 100644
--- a/layouts/flow.js
+++ b/layouts/flow.js
@@ -200,9 +200,13 @@ export class FlowLayout extends BaseLayout {
if (this._last < 0) {
return this._calculateAnchor(lower, upper);
}
+ if (this._last > this.items.length - 1) {
+ return this._calculateAnchor(lower, upper);
+ }
const firstItem = this._getPhysicalItem(this._first), lastItem = this._getPhysicalItem(this._last), firstMin = firstItem.pos, lastMin = lastItem.pos, lastMax = lastMin + this._metricsCache.getChildSize(this._last);
if (lastMax < lower) {
// Window is entirely past physical items, calculate new anchor
+
return this._calculateAnchor(lower, upper);
}
if (firstMin > upper) {
@@ -229,9 +233,13 @@ export class FlowLayout extends BaseLayout {
}
else {
this._getItems();
+ // We may be able to calculate scroll size more accurately after
+ // processing the latest measurements
+ this._refineScrollSize();
}
}
/**
+
* Sets the range to empty.
*/
_clearItems() {
@@ -395,8 +403,19 @@ export class FlowLayout extends BaseLayout {
}
_updateScrollSize() {
const { averageMarginSize } = this._metricsCache;
- this._scrollSize = Math.max(1, this.items.length * (averageMarginSize + this._getAverageSize()) +
- averageMarginSize);
+ this._scrollSize =
+ this.items.length * (averageMarginSize + this._getAverageSize()) +
+ averageMarginSize;
+ }
+ _refineScrollSize() {
+ // If all items are rendered, we can calculate the scroll size exactly
+ if (this._first === 0 && this._last === this.items.length - 1) {
+ this._scrollSize = this._physicalMax - this._physicalMin;
+ }
+ // Otherwise, we re-estimate with latest measurements
+ else {
+ this._updateScrollSize();
+ }
}
/**
* Returns the average size (precise or estimated) of an item in the scrolling direction,
4 changes: 2 additions & 2 deletions packages/components/grid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@
"@sl-design-system/text-field": "^1.5.0"
},
"devDependencies": {
"@lit-labs/virtualizer": "^2.0.14",
"@lit-labs/virtualizer": "patch:@lit-labs/virtualizer@npm%3A2.0.14#~/.yarn/patches/@lit-labs-virtualizer-npm-2.0.14-58a3230753.patch",
"@lit/localize": "^0.12.2",
"@open-wc/scoped-elements": "^3.0.5",
"lit": "^3.2.1"
},
"peerDependencies": {
"@lit-labs/virtualizer": "^2.0.13",
"@lit-labs/virtualizer": "^2.0.14",
"@lit/localize": "^0.12.1",
"@open-wc/scoped-elements": "^3.0.5",
"lit": "^3.1.4"
Expand Down
2 changes: 1 addition & 1 deletion packages/components/listbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@sl-design-system/icon": "^1.0.2"
},
"devDependencies": {
"@lit-labs/virtualizer": "^2.0.14",
"@lit-labs/virtualizer": "patch:@lit-labs/virtualizer@npm%3A2.0.14#~/.yarn/patches/@lit-labs-virtualizer-npm-2.0.14-58a3230753.patch",
"@open-wc/scoped-elements": "^3.0.5",
"lit": "^3.2.1"
},
Expand Down
4 changes: 3 additions & 1 deletion packages/locales/src/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,7 @@ export const templates = {
see63aaad45b1b116: 'status',
sf1ec4acb8d744ed9: 'Mededeling',
sf677da98fa27f9b6: 'Meer links',
sf7290005be5beae6: str`${0}, pagina`
sf7290005be5beae6: str`${0}, pagina`,
s874708ada8e71323: 'Skip to end of table',
se952fc198acfa288: 'Skip to start of table'
};
18 changes: 14 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3569,7 +3569,7 @@ __metadata:
languageName: node
linkType: hard

"@lit-labs/virtualizer@npm:^2.0.14":
"@lit-labs/virtualizer@npm:2.0.14":
version: 2.0.14
resolution: "@lit-labs/virtualizer@npm:2.0.14"
dependencies:
Expand All @@ -3579,6 +3579,16 @@ __metadata:
languageName: node
linkType: hard

"@lit-labs/virtualizer@patch:@lit-labs/virtualizer@npm%3A2.0.14#~/.yarn/patches/@lit-labs-virtualizer-npm-2.0.14-58a3230753.patch":
version: 2.0.14
resolution: "@lit-labs/virtualizer@patch:@lit-labs/virtualizer@npm%3A2.0.14#~/.yarn/patches/@lit-labs-virtualizer-npm-2.0.14-58a3230753.patch::version=2.0.14&hash=1776e1"
dependencies:
lit: "npm:^3.2.0"
tslib: "npm:^2.0.3"
checksum: 10c0/a69fc52bd4e01abf386cf63fd2dac03879e3564f5890eb2edf2ff652f12013178455b801e21310850660a5e97a5095fd58e411c80467ba8126e8bf5ab7f75c75
languageName: node
linkType: hard

"@lit/localize-tools@npm:^0.8.0":
version: 0.8.0
resolution: "@lit/localize-tools@npm:0.8.0"
Expand Down Expand Up @@ -4723,7 +4733,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@sl-design-system/grid@workspace:packages/components/grid"
dependencies:
"@lit-labs/virtualizer": "npm:^2.0.14"
"@lit-labs/virtualizer": "patch:@lit-labs/virtualizer@npm%3A2.0.14#~/.yarn/patches/@lit-labs-virtualizer-npm-2.0.14-58a3230753.patch"
"@lit/localize": "npm:^0.12.2"
"@open-wc/scoped-elements": "npm:^3.0.5"
"@sl-design-system/checkbox": "npm:^2.0.1"
Expand All @@ -4738,7 +4748,7 @@ __metadata:
"@sl-design-system/text-field": "npm:^1.5.0"
lit: "npm:^3.2.1"
peerDependencies:
"@lit-labs/virtualizer": ^2.0.13
"@lit-labs/virtualizer": ^2.0.14
"@lit/localize": ^0.12.1
"@open-wc/scoped-elements": ^3.0.5
lit: ^3.1.4
Expand Down Expand Up @@ -4790,7 +4800,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@sl-design-system/listbox@workspace:packages/components/listbox"
dependencies:
"@lit-labs/virtualizer": "npm:^2.0.14"
"@lit-labs/virtualizer": "patch:@lit-labs/virtualizer@npm%3A2.0.14#~/.yarn/patches/@lit-labs-virtualizer-npm-2.0.14-58a3230753.patch"
"@open-wc/scoped-elements": "npm:^3.0.5"
"@sl-design-system/icon": "npm:^1.0.2"
lit: "npm:^3.2.1"
Expand Down

0 comments on commit 73879be

Please sign in to comment.