Skip to content

fix(Grid): Add border to rendered height calc.#17157

Open
MayaKirova wants to merge 3 commits into21.1.xfrom
mkirova/fix-border-calc-21.1.x
Open

fix(Grid): Add border to rendered height calc.#17157
MayaKirova wants to merge 3 commits into21.1.xfrom
mkirova/fix-border-calc-21.1.x

Conversation

@MayaKirova
Copy link
Copy Markdown
Contributor

Closes #16640

Additional information (check all that apply):

  • Bug fix
  • New functionality
  • Documentation
  • Demos
  • CI/CD

Checklist:

  • All relevant tags have been applied to this PR
  • This PR includes unit tests covering all the new code (test guidelines)
  • This PR includes API docs for newly added methods/properties (api docs guidelines)
  • This PR includes feature/README.MD updates for the feature docs
  • This PR includes general feature table updates in the root README.MD
  • This PR includes CHANGELOG.MD updates for newly added functionality
  • This PR contains breaking changes
  • This PR includes ng update migrations for the breaking changes (migrations guidelines)
  • This PR includes behavioral changes and the feature specification has been updated with them

@MayaKirova MayaKirova requested a review from IMinchev64 April 3, 2026 13:11
Copilot AI review requested due to automatic review settings April 3, 2026 13:12
@MayaKirova MayaKirova added ❌ status: awaiting-test PRs awaiting manual verification grid labels Apr 3, 2026
Copy link
Copy Markdown
Contributor

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 an IgxGrid auto-sizing/percent-height edge case where applying a CSS border causes repeated rendered-height recalculation and continuous vertical growth by accounting for the grid’s top/bottom border widths in the rendered height calculation.

Changes:

  • Include border-top-width and border-bottom-width in the grid rendered height used for body height calculation.
  • Reuse a single getComputedStyle(...) call within the height calculation path.
  • Update the grid-auto-size sample styling to apply a border to igx-grid (to reproduce/verify the scenario).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/app/grid-auto-size/grid-auto-size.sample.scss Adds a border to the sample grid to reproduce the reported growth scenario.
projects/igniteui-angular/grids/grid/src/grid-base.directive.ts Adjusts rendered height computation to include border widths and avoids redundant computed-style lookups.

Comment on lines +7237 to +7249
const styles = this.document.defaultView.getComputedStyle(this.nativeElement);
const actualTheadRow = this.getTheadRowHeight();
const footerHeight = this.getFooterHeight();
const toolbarHeight = this.getToolbarHeight();
const pagingHeight = this.getPagingFooterHeight();
const groupAreaHeight = this.getGroupAreaHeight();
const scrHeight = this.getComputedHeight(this.scr.nativeElement);
const borderTop = parseFloat(styles.getPropertyValue('border-top-width')) || 0;
const borderBottom = parseFloat(styles.getPropertyValue('border-bottom-width')) || 0;

const renderedHeight = toolbarHeight + actualTheadRow +
footerHeight + pagingHeight + groupAreaHeight +
scrHeight;
scrHeight + borderTop + borderBottom;
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

This bug fix changes how body height is computed when borders are applied, but there is no unit/integration test covering the reported scenario (grid with percent height/width inside a container + CSS border leading to runaway growth). Please add a spec that renders an IgxGrid with 100% height and a non-zero border and asserts that the calculated body height stabilizes (no repeated size increases across change detection / resize observer cycles).

Copilot uses AI. Check for mistakes.
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.

3 participants