Skip to content

fix: fill viewport with ghost loader rows on initial load#683

Open
spike-rabbit wants to merge 1 commit intomainfrom
fix/ghost-loader-fill-viewport
Open

fix: fill viewport with ghost loader rows on initial load#683
spike-rabbit wants to merge 1 commit intomainfrom
fix/ghost-loader-fill-viewport

Conversation

@spike-rabbit
Copy link
Copy Markdown
Member

@spike-rabbit spike-rabbit commented Apr 29, 2026

What kind of change does this PR introduce? (check one with "x")

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

When using server-side scrolling with ghostLoadingIndicator, only a single undefined row 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 undefined rows 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 one undefined row is added as a bottom loading indicator.

Does this PR introduce a breaking change? (check one with "x")

  • Yes
  • No

Other information:

Affects the Scrolling server-side example

Added unit tests verifying:

  • Ghost rows fill viewport when loading with no data
  • Only one ghost row added as bottom indicator when data fills viewport
  • Ghost rows fill remaining space when partial data is loaded
  • No ghost rows added when ghostLoadingIndicator is false
  • No ghost rows added when scrollbarV is false

@spike-rabbit spike-rabbit requested a review from a team as a code owner April 29, 2026 13:00
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread projects/ngx-datatable/src/lib/components/datatable.component.ts Outdated
@spike-rabbit spike-rabbit force-pushed the fix/ghost-loader-fill-viewport branch 2 times, most recently from 52e24aa to 6b91851 Compare April 29, 2026 13:48
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.
@spike-rabbit spike-rabbit force-pushed the fix/ghost-loader-fill-viewport branch from 6b91851 to 7e7ce63 Compare April 29, 2026 13:55
@fh1ch fh1ch requested a review from Copilot April 30, 2026 12:47
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 viewportRowCount computed value to represent how many rows fit in the visible body.
  • Updates ghost-loading logic to append enough undefined rows 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.

Comment thread projects/ngx-datatable/src/lib/components/datatable.component.ts
Comment thread projects/ngx-datatable/src/lib/components/datatable.component.ts
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