Skip to content

Commit cf3f32f

Browse files
Splitter: Initially collapsed pane cannot be expanded if an adjacent pane's maxSize is specified (T1240306) (#28646) (#28649)
1 parent b3c594e commit cf3f32f

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

packages/devextreme/js/__internal/ui/splitter/utils/layout.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ export function findLastIndexOfNonCollapsedItem(items: Item[]): number {
4040
return -1;
4141
}
4242

43+
export function findLastVisibleExpandedItemIndex(items: Item[]): number {
44+
for (let i = items.length - 1; i >= 0; i -= 1) {
45+
const { collapsed, visible } = items[i];
46+
47+
if (collapsed !== true && visible !== false) {
48+
return i;
49+
}
50+
}
51+
return -1;
52+
}
53+
4354
export function findIndexOfNextVisibleItem(items: Item[], index: number): number {
4455
for (let i = index + 1; i < items.length; i += 1) {
4556
if (items[i].visible !== false) {

packages/devextreme/js/__internal/ui/splitter/utils/layout_default.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { toFixed } from '@js/common/core/localization/utils';
22
import { isDefined } from '@js/core/utils/type';
33

4-
import { findLastIndexOfVisibleItem, normalizePanelSize } from './layout';
4+
import {
5+
findLastIndexOfVisibleItem,
6+
findLastVisibleExpandedItemIndex,
7+
normalizePanelSize,
8+
} from './layout';
59
import { compareNumbersWithPrecision, PRECISION } from './number_comparison';
610
import type { PaneRestrictions } from './types';
711

@@ -135,9 +139,9 @@ export function getDefaultLayout(layoutRestrictions: PaneRestrictions[]): number
135139
}
136140

137141
if (remainingSize > 0) {
138-
const paneIndex = findLastIndexOfVisibleItem(layoutRestrictions);
142+
const paneIndex = findLastVisibleExpandedItemIndex(layoutRestrictions);
139143

140-
if (layoutRestrictions[paneIndex].collapsed === false) {
144+
if (paneIndex !== -1) {
141145
nextLayout[paneIndex] += remainingSize;
142146
}
143147
}

packages/devextreme/testing/tests/DevExpress.ui.widgets/splitter.tests.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,24 @@ QUnit.module('Pane sizing', moduleConfig, () => {
728728
}, {
729729
items: [{ }, { collapsed: true }],
730730
expectedLayout: ['100', '0'],
731+
}, {
732+
items: [{ maxSize: '75%' }, { collapsed: true }],
733+
expectedLayout: ['100', '0'],
734+
}, {
735+
items: [{ collapsed: true }, { visible: false }, { maxSize: '75%' }],
736+
expectedLayout: ['0', '0', '100'],
737+
}, {
738+
items: [{ maxSize: '75%' }, { visible: false }, { collapsed: true }],
739+
expectedLayout: ['100', '0', '0'],
740+
}, {
741+
items: [{ visible: false }, { collapsed: true }, { maxSize: '75%' }, { visible: false }],
742+
expectedLayout: ['0', '0', '100', '0'],
743+
}, {
744+
items: [{ visible: false }, { maxSize: '75%' }, { visible: false }, { collapsed: true }, { visible: false }],
745+
expectedLayout: ['0', '100', '0', '0', '0'],
746+
}, {
747+
items: [{ collapsed: true }, { maxSize: '75%' }],
748+
expectedLayout: ['0', '100'],
731749
}, {
732750
items: [{ collapsed: true }, { collapsed: true }, { collapsed: true }],
733751
expectedLayout: ['0', '0', '0'],
@@ -773,6 +791,8 @@ QUnit.module('Pane sizing', moduleConfig, () => {
773791
{ position: 'prev', expectedLayout: ['0', '100'], items: [{ maxSize: '75%', collapsible: true }, { collapsible: true }] },
774792
{ position: 'prev', expectedLayout: ['0', '100'], items: [{ maxSize: '75%', collapsible: true }, { collapsible: true }] },
775793
{ position: 'prev', expectedLayout: ['0', '100'], items: [{ maxSize: '75%', collapsible: true }, { collapsible: true }] },
794+
{ position: 'prev', expectedLayout: ['50', '50'], items: [{ maxSize: '75%', collapsible: false }, { collapsed: true, collapsible: true }] },
795+
{ position: 'next', expectedLayout: ['50', '50'], items: [{ collapsed: true, collapsible: true }, { maxSize: '75%', collapsible: false }] },
776796
{ position: 'prev', expectedLayout: ['10.0806', '89.9194'], items: [{ collapsible: true, collapsedSize: 100 }, { collapsible: true, collapsedSize: 100 }] },
777797
{ position: 'next', expectedLayout: ['89.9194', '10.0806'], items: [{ collapsible: true, collapsedSize: 100 }, { collapsible: true, collapsedSize: 100 }] },
778798
{ position: 'next', expectedLayout: ['100', '0'], items: [{ minSize: '15%', collapsible: true }, { collapsible: true }] },

0 commit comments

Comments
 (0)