Skip to content

Conversation

@latonv
Copy link
Contributor

@latonv latonv commented Aug 1, 2023

Currently, the infinite scroller on its first render pass creates empty shells for cell content, but the actual
cell content (or placeholders) is only subsequently rendered into those afterwards, outside of the usual Lit lifecycle.

This strategy has worked reasonably well, but it also leads to a number of undesired behaviors, including a resistance to SSR (which requires all content to be rendered on the first pass regardless of cell visibility) and unusual behavior when the content needs to be reloaded (flickering during the “empty shells” limbo, and manual effort required by the consumer to ensure prior pages of content actually get displayed when they load in).

This PR updates the infinite scroller component to preserve its scroll-optimized behavior while also making its render cycles much more standard for a Lit component, which should make it easier to work with overall. To accomplish this, instead of rendering directly into cell containers upon visibility changes, we just update which sets of cell indices should render content/placeholder/nothing and kick off a proper component render pass to actually fill the cells with that content the usual declarative Lit way.

Previously, the first render pass would create
empty shells for cell content, but the actual
cell content (or placeholders) would subsequently
be rendered into those outside of the usual
Lit lifecycle.

However, this causes a number of undesired
behaviors, including a resistance to SSR
(which requires all content to be rendered
on the first pass regardless of visibility)
and unusual behavior when the content needs
to be reloaded (flickering during the empty
shell limbo, and manual effort required
by the consumer to ensure prior pages of
content becoming visible actually triggers
the right events).

With this update, we keep the scroll-optimized
behavior while making the render cycles
much more ordinary for a Lit component,
which should make the infinite scroller
easier to work with overall.
@codecov
Copy link

codecov bot commented Aug 1, 2023

Codecov Report

Merging #7 (64f6b96) into main (c775985) will increase coverage by 0.60%.
Report is 1 commits behind head on main.
The diff coverage is 84.21%.

❗ Current head 64f6b96 differs from pull request most recent head cfeccb4. Consider uploading reports for the commit cfeccb4 to get more accurate results

@@            Coverage Diff             @@
##             main       #7      +/-   ##
==========================================
+ Coverage   89.91%   90.52%   +0.60%     
==========================================
  Files           3        3              
  Lines         486      517      +31     
  Branches       24       23       -1     
==========================================
+ Hits          437      468      +31     
  Misses         49       49              
Files Changed Coverage Δ
src/infinite-scroller.ts 89.81% <84.21%> (+0.70%) ⬆️

@latonv latonv changed the title WEBDEV-6266 Render cells within the usual component lifecycle Draft: WEBDEV-6266 Render cells within the usual component lifecycle Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants