[trees][wip] Create a new /scroll export for a self-virtualizable file tree#615
[trees][wip] Create a new /scroll export for a self-virtualizable file tree#615SlexAxton wants to merge 5 commits into
/scroll export for a self-virtualizable file tree#615Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2f66cbbe8b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| return ( | ||
| scrollContainer.getBoundingClientRect().top - | ||
| host.getBoundingClientRect().top | ||
| ); |
There was a problem hiding this comment.
Compute viewportTop from the scrollport edge
createDomScrollSource currently derives viewportTop from scrollContainer.getBoundingClientRect().top, which is the container’s border-box top. For scroll containers with a non-zero top border, this reports a viewport that is shifted upward by the border width, so virtualization/sticky math and scrollToViewportTop(...) requests are consistently off by that amount. This shows up in common bordered panels and causes reveal positioning drift; use the scrollport edge (e.g. include clientTop) when computing the host-local viewport top.
Useful? React with 👍 / 👎.
8bf19ee to
5490162
Compare
Summary
This PR introduces a dedicated @pierre/trees/scroll entry point for the
external-scroll integration.
The goal is to keep the normal @pierre/trees path focused on the built-in internal
scroller, while moving caller-owned scroll-container support behind an explicit
advanced import.
With this change:
What this adds
New public entry point
@pierre/trees/scroll
It exports:
New external-scroll helper
createDomScrollSource(...)
This covers the common “tree inside a normal page scroller” case:
React reuse without a separate /scroll/react
External-scroll models created from @pierre/trees/scroll can still render through:
That means the advanced model is new, but the React view layer stays shared.
Behavioral change
External-scroll setup is no longer part of the root @pierre/trees surface.
If you were previously doing this through the root package:
you now need to move those integrations to @pierre/trees/scroll.
Normal internal-scroll trees are unchanged in how they are created and rendered.
How to use it
Vanilla / imperative usage
Cleanup:
React usage
Create the model from @pierre/trees/scroll, but keep using the shared React component
from @pierre/trees/react.
SSR usage
Use the scroll entry point for preloading too:
Contract for custom sources
If you implement your own FileTreeExternalScrollSource, the important contract is:
returning
That synchronous update matters because the tree recalculates layout immediately after
requesting scroll movement.
Why this split exists
This keeps the advanced external-scroll feature explicit and opt-in: