Skip to content

Splitter: size of panes should be updated taking into account their limitations on splitter resize#32862

Open
pharret31 wants to merge 4 commits intoDevExpress:26_1from
pharret31:26_1_3660-splitter-size-of-panes-should-be-updated-taking-into-account-their-limitations-on-splitter-resize
Open

Splitter: size of panes should be updated taking into account their limitations on splitter resize#32862
pharret31 wants to merge 4 commits intoDevExpress:26_1from
pharret31:26_1_3660-splitter-size-of-panes-should-be-updated-taking-into-account-their-limitations-on-splitter-resize

Conversation

@pharret31
Copy link
Contributor

No description provided.

@pharret31 pharret31 self-assigned this Mar 11, 2026
@pharret31 pharret31 added the 26_1 label Mar 11, 2026
@pharret31 pharret31 marked this pull request as ready for review March 11, 2026 10:07
@pharret31 pharret31 requested a review from a team as a code owner March 11, 2026 10:07
Copilot AI review requested due to automatic review settings March 11, 2026 10:07
Copy link
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

Updates Splitter’s dimension-change handling so pane sizes/layout are recalculated in a way that respects pane constraints (min/max/fixed sizes) when the splitter is resized, and expands the QUnit coverage for these scenarios.

Changes:

  • Reorders _dimensionChanged() to recalculate layout, apply it to DOM, then update stored item sizes.
  • Updates an existing resizing test expectation to match the new constraint-aware behavior.
  • Adds a set of new tests validating that minSize/maxSize constraints are respected after splitter width changes.

Reviewed changes

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

File Description
packages/devextreme/testing/tests/DevExpress.ui.widgets/splitter.tests.js Updates one existing resize test and adds new cases covering constraint enforcement after dimension changes.
packages/devextreme/js/__internal/ui/splitter/splitter.ts Changes dimension-change flow to apply the recalculated layout before persisting new pane sizes.

Comment on lines 1102 to +1106
_dimensionChanged(): void {
this._updateItemSizes();

this._layout = this._getDefaultLayoutBasedOnSize();
this._applyStylesFromLayout(this._layout);

this._updateItemSizes();
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

_dimensionChanged() now recalculates layout and applies flex styles before updating item sizes. If width/height is changed while the splitter is hidden or detached, getElementSize() can be 0 while _getResizeHandlesSize() is non-zero, which can produce negative ratios in convertSizeToRatio() and an invalid layout that then gets applied to the DOM. Consider guarding _dimensionChanged similarly to _resizeHandler/_renderItems (e.g., if not attached/visible, set _shouldRecalculateLayout = true and return without applying styles), so the layout is recalculated once the component becomes visible.

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings March 18, 2026 11:13
Copy link
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

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

Comment on lines +1160 to +1163
const originalSize = this._initialPaneSizes[index];

if (isDefined(originalSize)) {
const fixedPx = tryConvertToNumber(originalSize, elementSize) ?? px;
Comment on lines +1225 to +1228
const fallback = findLastVisibleExpandedItemIndex(items);

if (fallback !== -1) {
pixels[fallback] += remaining;
@pharret31 pharret31 force-pushed the 26_1_3660-splitter-size-of-panes-should-be-updated-taking-into-account-their-limitations-on-splitter-resize branch from cac954d to 49bbb53 Compare March 26, 2026 17:55
Copilot AI review requested due to automatic review settings March 27, 2026 11:02
Copy link
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

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

if (eligiblePaneIndices.length === 0) {
const fallback = findLastVisibleExpandedItemIndex(items);

if (fallback !== -1) {
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

In _distributeRemainingPixels, the fallback path applies pixels[fallback] += remaining even when remaining is negative. If all panes are already clamped at their minSize (or fixed size), eligiblePaneIndices becomes empty and this can drive the fallback pane size below 0 (and below its min/max), resulting in negative flexGrow/sizes. Suggestion: only apply the fallback when remaining > 0 (extra space), and when remaining < 0 just stop distributing (allow overflow) or clamp the fallback so it cannot go below 0/minSize.

Suggested change
if (fallback !== -1) {
if (fallback !== -1 && remaining > 0) {

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.

2 participants