Skip to content

Commit 6f1c0ef

Browse files
Splitter: resizeHandle should not be duplicated when changing the template option at runtime (T1279224) (DevExpress#29466)
1 parent c33ba6d commit 6f1c0ef

File tree

3 files changed

+72
-1
lines changed

3 files changed

+72
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ class Splitter extends CollectionWidgetLiveUpdate<Properties> {
547547
event,
548548
handleElement: getPublicElement<HTMLElement>($resizeHandle),
549549
};
550-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
550+
551551
this._feedbackDeferred?.resolve();
552552
this._toggleActiveState($resizeHandle, false);
553553

@@ -688,6 +688,12 @@ class Splitter extends CollectionWidgetLiveUpdate<Properties> {
688688
this._itemVisibleOptionChanged(item, value as PropertyType, prevValue as PropertyType);
689689
break;
690690
}
691+
case 'template':
692+
super._itemOptionChanged(item, property, value, prevValue);
693+
694+
this._applyStylesFromLayout(this.getLayout());
695+
this._updateResizeHandles();
696+
break;
691697
default:
692698
super._itemOptionChanged(item, property, value, prevValue);
693699
}

packages/devextreme/js/__internal/ui/splitter/splitter_item.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ class SplitterItem extends CollectionWidgetItem<Item> {
8282
isLast(): boolean {
8383
return this._owner._isLastVisibleItem(this.getIndex());
8484
}
85+
86+
_dispose(): void {
87+
this._removeResizeHandle();
88+
89+
super._dispose();
90+
}
8591
}
8692

8793
export default SplitterItem;

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

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,6 +1607,47 @@ QUnit.module('Pane visibility', moduleConfig, () => {
16071607
});
16081608
});
16091609

1610+
QUnit.module('Pane.template', moduleConfig, () => {
1611+
QUnit.test('ResizeHandle should not be duplicated when changing the template option at runtime (T1279224)', function(assert) {
1612+
const firstPaneTemplate = () => $('<div>').text('Pane 1');
1613+
const secondPaneTemplate = () => $('<div>').text('Pane 2');
1614+
1615+
this.reinit({
1616+
dataSource: [{
1617+
template: firstPaneTemplate
1618+
}, {
1619+
template: secondPaneTemplate
1620+
}]
1621+
});
1622+
1623+
this.instance.option({
1624+
'items[0].template': secondPaneTemplate,
1625+
'items[1].template': firstPaneTemplate,
1626+
});
1627+
1628+
assert.strictEqual(this.getResizeHandles().length, 1);
1629+
});
1630+
1631+
QUnit.test('Layout should restore the distribution when changing the template option at runtime (T1279224)', function(assert) {
1632+
const firstPaneTemplate = () => $('<div>').text('Pane 1');
1633+
const secondPaneTemplate = () => $('<div>').text('Pane 2');
1634+
1635+
this.reinit({
1636+
dataSource: [{
1637+
size: '300px',
1638+
template: firstPaneTemplate
1639+
}, {
1640+
template: secondPaneTemplate
1641+
}]
1642+
});
1643+
1644+
this.instance.option('items[0].template', secondPaneTemplate);
1645+
1646+
this.checkItemSizes([300, 692]);
1647+
this.assertLayout(['30.2419', '69.7581']);
1648+
});
1649+
});
1650+
16101651
QUnit.module('Resizing', moduleConfig, () => {
16111652
['horizontal', 'vertical'].forEach(orientation => {
16121653
QUnit.test(`collapsed pane should move its neighboring pane on expansion to left, orientation ${orientation}`, function(assert) {
@@ -2931,6 +2972,24 @@ QUnit.module('Visibility of control elements', {
29312972
});
29322973
});
29332974
});
2975+
2976+
QUnit.test('ResizeHandle control elements visibility should be updated when changing the template option at runtime (T1279224)', function(assert) {
2977+
const firstPaneTemplate = () => $('<div>').text('Pane 1');
2978+
const secondPaneTemplate = () => $('<div>').text('Pane 2');
2979+
2980+
this.reinit({
2981+
dataSource: [{
2982+
template: firstPaneTemplate
2983+
}, {
2984+
template: secondPaneTemplate,
2985+
collapsible: true,
2986+
}]
2987+
});
2988+
2989+
this.instance.option('items[0].template', secondPaneTemplate);
2990+
2991+
this.checkIconsVisibility([{ prev: false, resize: true, next: true }]);
2992+
});
29342993
});
29352994

29362995
QUnit.module('Events', moduleConfig, () => {

0 commit comments

Comments
 (0)