Skip to content

Commit

Permalink
Make virtualization compatible with overflow:scroll on document/body. F…
Browse files Browse the repository at this point in the history
…ixes #37659
  • Loading branch information
SteveSandersonMS committed Jun 28, 2022
1 parent 07edd3c commit 2b36530
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Components/Web.JS/dist/Release/blazor.server.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Components/Web.JS/dist/Release/blazor.webview.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion src/Components/Web.JS/src/Virtualize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ export const Virtualize = {
const observersByDotNetId = {};

function findClosestScrollContainer(element: HTMLElement | null): HTMLElement | null {
if (!element) {
// If we recurse up as far as body or the document root, return null so that the
// IntersectionObserver observes intersection with the top-level scroll viewport
// instead of the with body/documentElement which can be arbitrarily tall.
// See https://github.com/dotnet/aspnetcore/issues/37659 for more about what this fixes.
if (!element || element === document.body || element === document.documentElement) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
</tbody>
</table>

<style>
/* Represents https://github.com/dotnet/aspnetcore/issues/37659 */
html, body { overflow-y: scroll }
</style>

@code {
List<int> fixedItems = Enumerable.Range(0, 1000).ToList();
}

0 comments on commit 2b36530

Please sign in to comment.