fix: fill viewport with ghost loader rows on initial load#683
fix: fill viewport with ghost loader rows on initial load#683spike-rabbit wants to merge 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the ghost loading logic in ngx-datatable to fill the viewport with ghost rows by calculating the difference between the page size and the current row count. It also introduces a suite of unit tests to verify this behavior under various conditions. A critical issue was identified where calling pageSize() within the _internalRows computed signal creates a circular dependency and a potential infinite loop if rowHeight is zero; a suggestion was provided to calculate viewport capacity directly to avoid these issues.
52e24aa to
6b91851
Compare
When using server-side scrolling with ghostLoadingIndicator, only a single undefined row was pushed into _internalRows, resulting in just one ghost skeleton row visible during initial load. Now pushes enough undefined rows to fill the viewport (pageSize - rows.length, minimum 1), so the ghost loader fills the entire body area before data arrives.
6b91851 to
7e7ce63
Compare
There was a problem hiding this comment.
Pull request overview
Fixes ghost loading behavior for server-side scrolling so the initial skeleton rows fill the viewport instead of only rendering 1–2 rows, improving perceived loading behavior in the Scrolling server-side example.
Changes:
- Introduces a
viewportRowCountcomputed value to represent how many rows fit in the visible body. - Updates ghost-loading logic to append enough
undefinedrows to fill the viewport (minimum 1). - Updates
calcPageSize()to reuse the shared viewport row count logic. - Adds unit tests covering ghost row behavior across empty/partial/full data and feature toggles.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| projects/ngx-datatable/src/lib/components/datatable.component.ts | Computes viewport row count and uses it to generate ghost rows and page size under virtualization. |
| projects/ngx-datatable/src/lib/components/datatable.component.spec.ts | Adds tests asserting ghost row counts under various loading/data conditions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
What kind of change does this PR introduce? (check one with "x")
What is the current behavior?
When using server-side scrolling with
ghostLoadingIndicator, only a singleundefinedrow was pushed into_internalRows, resulting in just one or two ghost skeleton rows visible during initial load instead of filling the entire viewport.What is the new behavior?
Now pushes enough
undefinedrows to fill the viewport (pageSize - rows.length, minimum 1), so the ghost loader fills the entire body area before data arrives. When data already fills the viewport, only oneundefinedrow is added as a bottom loading indicator.Does this PR introduce a breaking change? (check one with "x")
Other information:
Affects the
Scrolling server-sideexampleAdded unit tests verifying:
ghostLoadingIndicatoris falsescrollbarVis false