Skip to content

Commit

Permalink
Splitter: Initially collapsed pane cannot be expanded if an adjacent …
Browse files Browse the repository at this point in the history
…pane's maxSize is specified (T1240306) (#28646) (#28652)
  • Loading branch information
EugeniyKiyashko authored Dec 27, 2024
1 parent 4e9afaf commit 49226ff
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
11 changes: 11 additions & 0 deletions packages/devextreme/js/__internal/ui/splitter/utils/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ export function findLastIndexOfNonCollapsedItem(items: Item[]): number {
return -1;
}

export function findLastVisibleExpandedItemIndex(items: Item[]): number {
for (let i = items.length - 1; i >= 0; i -= 1) {
const { collapsed, visible } = items[i];

if (collapsed !== true && visible !== false) {
return i;
}
}
return -1;
}

export function findIndexOfNextVisibleItem(items: Item[], index: number): number {
for (let i = index + 1; i < items.length; i += 1) {
if (items[i].visible !== false) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { isDefined } from '@js/core/utils/type';
import { toFixed } from '@js/localization/utils';

import { findLastIndexOfVisibleItem, normalizePanelSize } from './layout';
import {
findLastIndexOfVisibleItem,
findLastVisibleExpandedItemIndex,
normalizePanelSize,
} from './layout';
import { compareNumbersWithPrecision, PRECISION } from './number_comparison';
import type { PaneRestrictions } from './types';

Expand Down Expand Up @@ -135,9 +139,9 @@ export function getDefaultLayout(layoutRestrictions: PaneRestrictions[]): number
}

if (remainingSize > 0) {
const paneIndex = findLastIndexOfVisibleItem(layoutRestrictions);
const paneIndex = findLastVisibleExpandedItemIndex(layoutRestrictions);

if (layoutRestrictions[paneIndex].collapsed === false) {
if (paneIndex !== -1) {
nextLayout[paneIndex] += remainingSize;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,24 @@ QUnit.module('Pane sizing', moduleConfig, () => {
}, {
items: [{ }, { collapsed: true }],
expectedLayout: ['100', '0'],
}, {
items: [{ maxSize: '75%' }, { collapsed: true }],
expectedLayout: ['100', '0'],
}, {
items: [{ collapsed: true }, { visible: false }, { maxSize: '75%' }],
expectedLayout: ['0', '0', '100'],
}, {
items: [{ maxSize: '75%' }, { visible: false }, { collapsed: true }],
expectedLayout: ['100', '0', '0'],
}, {
items: [{ visible: false }, { collapsed: true }, { maxSize: '75%' }, { visible: false }],
expectedLayout: ['0', '0', '100', '0'],
}, {
items: [{ visible: false }, { maxSize: '75%' }, { visible: false }, { collapsed: true }, { visible: false }],
expectedLayout: ['0', '100', '0', '0', '0'],
}, {
items: [{ collapsed: true }, { maxSize: '75%' }],
expectedLayout: ['0', '100'],
}, {
items: [{ collapsed: true }, { collapsed: true }, { collapsed: true }],
expectedLayout: ['0', '0', '0'],
Expand Down Expand Up @@ -773,6 +791,8 @@ QUnit.module('Pane sizing', moduleConfig, () => {
{ position: 'prev', expectedLayout: ['0', '100'], items: [{ maxSize: '75%', collapsible: true }, { collapsible: true }] },
{ position: 'prev', expectedLayout: ['0', '100'], items: [{ maxSize: '75%', collapsible: true }, { collapsible: true }] },
{ position: 'prev', expectedLayout: ['0', '100'], items: [{ maxSize: '75%', collapsible: true }, { collapsible: true }] },
{ position: 'prev', expectedLayout: ['50', '50'], items: [{ maxSize: '75%', collapsible: false }, { collapsed: true, collapsible: true }] },
{ position: 'next', expectedLayout: ['50', '50'], items: [{ collapsed: true, collapsible: true }, { maxSize: '75%', collapsible: false }] },
{ position: 'prev', expectedLayout: ['10.0806', '89.9194'], items: [{ collapsible: true, collapsedSize: 100 }, { collapsible: true, collapsedSize: 100 }] },
{ position: 'next', expectedLayout: ['89.9194', '10.0806'], items: [{ collapsible: true, collapsedSize: 100 }, { collapsible: true, collapsedSize: 100 }] },
{ position: 'next', expectedLayout: ['100', '0'], items: [{ minSize: '15%', collapsible: true }, { collapsible: true }] },
Expand Down

0 comments on commit 49226ff

Please sign in to comment.