fix(splitter): preserve pane sizes after collapse - 21.2.x - #17555
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The new/updated tests use strict layout equality assertions that are likely flaky across environments, and there’s a small but concrete performance improvement available in the updated flex-grow condition.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR updates the Splitter pane collapse/expand behavior to preserve configured pane sizes and constraints, preventing panes from “forgetting” their previous dimensions after a collapse cycle (addressing #17545).
Changes:
- Stops resetting pane sizes/constraints during pane initialization when collapsed panes are present.
- Updates
IgxSplitterPaneflex behavior so fixed-size siblings can temporarily grow to fill released space while a neighbor is collapsed, while clearing only temporary drag sizes. - Adds/updates unit tests covering collapse/expand for horizontal/vertical splitters, fixed-size panes, initial collapse, and drag-size cleanup.
File summaries
| File | Description |
|---|---|
| projects/igniteui-angular/splitter/src/splitter/splitter.component.ts | Removes init-time size reset when panes are collapsed to preserve configured sizing. |
| projects/igniteui-angular/splitter/src/splitter/splitter.component.spec.ts | Adds new regression tests for preserving sizes/constraints and clearing drag sizes on collapse/expand. |
| projects/igniteui-angular/splitter/src/splitter/splitter-pane/splitter-pane.component.ts | Adjusts flex-grow calculation to allow fixed-size siblings to fill space when adjacent pane is collapsed; refactors owner handling and drag-size reset. |
Review details
Suppressed comments (3)
projects/igniteui-angular/splitter/src/splitter/splitter.component.spec.ts:295
- Similar to the horizontal case, strict equality on
offsetHeightcan be brittle due to layout rounding and browser differences. Consider usingtoBeCloseTo(..., 0)for stability, consistent with other resize assertions in this spec.
expect(pane1.element.offsetHeight).toBe(pane1Height);
expect(pane2.element.offsetHeight).toBe(pane2Height);
projects/igniteui-angular/splitter/src/splitter/splitter.component.spec.ts:319
- Strict equality on
offsetWidthhere may also be flaky (box model, scrollbars, fractional pixels). UsingtoBeCloseTo(or rounding) would better reflect the intent: sizes should restore approximately to the pre-collapse widths.
expect(pane1.element.offsetWidth).toBe(pane1Width);
expect(pane2.element.offsetWidth).toBe(pane2Width);
projects/igniteui-angular/splitter/src/splitter/splitter.component.spec.ts:553
- This strict array equality on
offsetWidthcan be sensitive to small layout differences across browsers/CI (e.g. 99/101px due to rounding). Rounding (ortoBeCloseToper-pane) would make the assertion less flaky while still validating the restore behavior.
expect(panes.map(pane => pane.element.offsetWidth)).toEqual([100, 100, 100]);
- Files reviewed: 3/3 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
| public get flex() { | ||
| const size = this.dragSize || this.size; | ||
| const grow = this.isPercentageSize && !this.dragSize ? 1 : 0; | ||
| const grow = (this.isPercentageSize || this.hasCollapsedSibling) && !this.dragSize ? 1 : 0; | ||
| return `${grow} ${grow} ${size}`; |
Closes #17545
Description
This PR prevents
IgxSplitterPanefrom losing its configured size after being collapsed and expanded.Previously, collapsing a pane reset its siblings to
size="auto", which caused horizontal panes to lose their previous width. The updated behavior:Testing
Added coverage for horizontal and vertical splitters, fixed-size panes, initial collapse, and temporary drag-size cleanup.
Motivation / Context
Type of Change (check all that apply):
Component(s) / Area(s) Affected:
How Has This Been Tested?
Test Configuration:
Screenshots / Recordings
Checklist:
feature/README.MDupdates for the feature docsREADME.MDCHANGELOG.MDupdates for newly added functionalityng updatemigrations for the breaking changes (migrations guidelines)