Skip to content

Conversation

@spike-rabbit
Copy link
Member

@spike-rabbit spike-rabbit commented Oct 29, 2025

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? (You can also link to an open issue here)

When using <ngx-datatable-row-detail [rowHeight]="function">, the function was called sporadically with a wrong index. This is due to a bug in the body-component, where the rendered offset-index was passed to the cache.

What is the new behavior?

The cache is operating on all rows, not the rendered ones. So instead of rendered-offset, we need to pass only the offset, if external paging is enabled.

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

  • Yes
  • No

If this PR contains a breaking change, please describe the impact and migration path for existing applications: ...

Other information:

I don't think, the index is actually used to compute the detailsHeight. But at least it is correct now.
The main motivation here is actually to avoid circular references so I can make more things computed.

@spike-rabbit spike-rabbit requested a review from a team as a code owner October 29, 2025 07:47
@spike-rabbit spike-rabbit force-pushed the fix/body/always-call-details-row-height-with-correct-index branch from eb40aa5 to c14135b Compare October 29, 2025 08:50
@spike-rabbit spike-rabbit mentioned this pull request Oct 29, 2025
9 tasks
@fh1ch fh1ch requested a review from Copilot October 30, 2025 17:09
Copy link

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

This PR fixes an issue with row detail height calculation in external paging mode by correcting the indexOffset parameter passed to the row height cache. Previously, the index offset was incorrectly using indexes().first, which is always 0 in external paging mode, causing incorrect indices to be passed to detailRowHeight callbacks on pages beyond the first.

  • Changed indexOffset calculation in computeRowHeightsCache() to properly account for external paging
  • Added comprehensive tests for row detail directive behavior with row expansion/collapse

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
projects/ngx-datatable/src/lib/components/body/body.component.ts Fixed indexOffset calculation to use offset() * pageSize() for external paging instead of indexes().first
projects/ngx-datatable/src/lib/components/row-detail/row-detail.spec.ts Added test suite for DatatableRowDetailDirective with tests for row expansion/collapse and index verification

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…with correct index

Previously, when using `<ngx-datatable-row-detail [rowHeight]="function">`, the function
was called sporadically with a wrong index.
This is due to a bug in the body-component, where the rendered offset-index was passed to the
cache. But the cache is operating on all rows, not the rendered ones.
So instead, we need to pass only the offset, if external paging is enabled.
@fh1ch fh1ch force-pushed the fix/body/always-call-details-row-height-with-correct-index branch from c14135b to eecbadc Compare October 30, 2025 17:11
Copy link
Member

@fh1ch fh1ch left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@fh1ch fh1ch enabled auto-merge (rebase) October 30, 2025 17:12
@fh1ch fh1ch merged commit 4076829 into main Oct 30, 2025
3 checks passed
@fh1ch fh1ch deleted the fix/body/always-call-details-row-height-with-correct-index branch October 30, 2025 17:15
@siemens-element-bot
Copy link
Collaborator

🎉 This PR is included in version 24.3.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants