Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ test.meta({ browserSize: [800, 800] })('non resizable pane should not change its

await t
.expect(splitter.getItem(2).element.clientWidth)
.eql(145);
.eql(300);
}).before(async () => createWidget('dxSplitter', {
width: '100%',
height: 300,
Expand Down
5 changes: 3 additions & 2 deletions packages/devextreme/js/__internal/ui/splitter/splitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1100,9 +1100,10 @@ class Splitter extends CollectionWidgetLiveUpdate<Properties> {
}

_dimensionChanged(): void {
this._updateItemSizes();

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

this._updateItemSizes();
Comment on lines 1102 to +1106
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.
}

_optionChanged(args: OptionChanged<Properties>): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1973,8 +1973,8 @@ QUnit.module('Resizing', moduleConfig, () => {

this.instance.option(orientation === 'horizontal' ? 'width' : 'height', 700);

this.checkItemSizes([159.133, 159.133, 159.133, 204.602]);
this.assertLayout([23.3333, 23.3333, 23.3333, 30]);
this.checkItemSizes([0, 166.664, 215.336, 300]);
this.assertLayout([0, 24.4375, 31.5742, 43.9883]);
});
});

Expand Down Expand Up @@ -2822,6 +2822,75 @@ QUnit.module('Resizing', moduleConfig, () => {

this.assertLayout(['15', '10', '25', '50']);
});

[{
initialWidth: 408,
newWidth: 808,
dataSource: [{ size: '200px', maxSize: '200px' }, { }],
expectedLayout: ['25', '75'],
expectedItemSizes: [200, 600],
}, {
initialWidth: 408,
newWidth: 808,
dataSource: [{ }, { size: '200px', maxSize: '200px' }],
expectedLayout: ['75', '25'],
expectedItemSizes: [600, 200],
}, {
initialWidth: 808,
newWidth: 408,
dataSource: [{ size: '200px', minSize: '200px' }, { }],
expectedLayout: ['50', '50'],
expectedItemSizes: [200, 200],
}, {
initialWidth: 808,
newWidth: 408,
dataSource: [{ }, { size: '200px', minSize: '200px' }],
expectedLayout: ['50', '50'],
expectedItemSizes: [200, 200],
}, {
initialWidth: 416,
newWidth: 816,
dataSource: [{ size: '200px', maxSize: '200px' }, { }, { }],
expectedLayout: ['25', '12.5', '62.5'],
expectedItemSizes: [200, 100, 500],
}, {
initialWidth: 816,
newWidth: 416,
dataSource: [{ size: '200px', minSize: '200px' }, { }, { }],
expectedLayout: ['50', '50', '0'],
expectedItemSizes: [200, 200, 0],
}, {
initialWidth: 416,
newWidth: 816,
dataSource: [{ }, { size: '200px', maxSize: '200px' }, { }],
expectedLayout: ['12.5', '25', '62.5'],
expectedItemSizes: [100, 200, 500],
}, {
initialWidth: 416,
newWidth: 816,
dataSource: [{ size: '200px', minSize: '100px', maxSize: '300px' }, { }],
expectedLayout: ['24.7525', '75.2475'],
expectedItemSizes: [200, 608],
}, {
initialWidth: 208,
newWidth: 808,
dataSource: [{ size: '100px', maxSize: '200px' }, { }],
expectedLayout: ['12.5', '87.5'],
expectedItemSizes: [100, 700],
}].forEach(({ initialWidth, newWidth, dataSource, expectedLayout, expectedItemSizes }) => {
QUnit.test(`pane constraints should be respected after dimension change from ${initialWidth} to ${newWidth}, dataSource: ${JSON.stringify(dataSource)}`, function(assert) {
this.reinit({
width: initialWidth,
height: 408,
dataSource,
});

this.instance.option('width', newWidth);

this.checkItemSizes(expectedItemSizes);
this.assertLayout(expectedLayout);
});
});
});

QUnit.module('Initialization', moduleConfig, () => {
Expand Down