fix(splitter): preserve pane sizes after collapse - #17553
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The new unit tests rely on strict offsetWidth/offsetHeight equality, which is likely to be flaky due to rounding/layout differences across runs and environments.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR updates the Splitter collapse/expand behavior so IgxSplitterPane preserves its configured sizes (and min/max constraints) instead of resetting sibling sizes to auto, addressing the “restore original size after expand” regression described in #17545.
Changes:
- Removed the initialization-time size reset that triggered when any panes were collapsed.
- Updated pane collapse handling to preserve
sizewhile clearing only temporarydragSize, and to allow adjacent fixed-size panes to flex-fill released space during a collapse. - Added/updated unit tests covering horizontal/vertical collapse/expand, fixed-size siblings, initially-collapsed panes, and drag-size cleanup.
File summaries
| File | Description |
|---|---|
| projects/igniteui-angular/splitter/src/splitter/splitter.component.ts | Stops resetting pane sizes during pane initialization when a pane starts collapsed. |
| projects/igniteui-angular/splitter/src/splitter/splitter.component.spec.ts | Adds coverage for preserving sizes/constraints across collapse/expand, including fixed-size and initially-collapsed scenarios. |
| projects/igniteui-angular/splitter/src/splitter/splitter-pane/splitter-pane.component.ts | Adjusts flex behavior to preserve configured sizes, clear only drag sizes on collapse changes, and allow fill behavior while a sibling is collapsed. |
Review details
Suppressed comments (2)
projects/igniteui-angular/splitter/src/splitter/splitter.component.spec.ts:551
- Asserting exact pixel widths for all panes (
toEqual([100, 100, 100])) may be brittle if splitter bars/borders/padding affectoffsetWidthby a pixel. A tolerance-based assertion is typically more stable.
expect(panes.map(pane => pane.element.offsetWidth)).toEqual([100, 100, 100]);
projects/igniteui-angular/splitter/src/splitter/splitter.component.spec.ts:319
- These strict
offsetWidthequality assertions can be flaky due to rounding/layout differences after toggling collapse (even when the configured sizes are preserved). Consider asserting within a small pixel tolerance instead.
expect(pane1.element.offsetWidth).toBe(pane1Width);
expect(pane2.element.offsetWidth).toBe(pane2Width);
- 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.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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)