New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: lit integration #718
base: main
Are you sure you want to change the base?
Conversation
☁️ Nx Cloud ReportCI is running/has finished running commands for commit d783e40. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution
Sent with 💌 from NxCloud. |
@tannerlinsley @piecyk how can we move forward with this? :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kadoshms awesome work 🥇 Had a quick look on adapter and added two comments, will check the examples letter but overall i think we can merge it soonish 👏
packages/lit-virtual/src/index.ts
Outdated
this.cleanup = this.virtualizer._didMount() | ||
this.virtualizer._willUpdate() | ||
await this.host.updateComplete | ||
this.host.requestUpdate() | ||
this.virtualizer.measure() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm why not?
this.cleanup = this.virtualizer._didMount() | |
this.virtualizer._willUpdate() | |
await this.host.updateComplete | |
this.host.requestUpdate() | |
this.virtualizer.measure() | |
this.cleanup = this.virtualizer._didMount() | |
this.virtualizer._willUpdate() |
as _willUpdate will set up event listeners and call onChange if needed, there we have requestUpdate, the measure is pretty a hack to clear cache and call onChange
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I started with this approach at the beginning, but for some reason in the Columns example, if failed to size the columns right, it would fix only after a scroll event was triggered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue here is that for initial measure, when we call measureElement node.isConnected
will return false for some reason https://github.com/TanStack/virtual/blob/main/packages/virtual-core/src/index.ts#L648
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I see, that's mainly because on the first render the ref
will be undefined
, and virtual dynamic nodes aren't connected yet, but this "gets fixed" by immediately measuring and invoking a render.
There was indeed a redundant _willUpdate
which I removed, but the rest I'm not sure it's possible without touching the core.
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @piecyk, it's been a while :) do we plan to move forward with this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kadoshms Yes we do! Sorry for delay, need to look again on this node.isConnected because the whole dynamic case is based on it.
Lit is a growing library for building web-components with ease.
This PR introduces
@tanstack/lit-virtual
integration package for creating virtualized elements using Lit's Reactive ControllersI guess there's more room for improvement and testing, but it could definitely be a start for this.