Skip to content

Commit e2cce8d

Browse files
Splitter, MessageList: unobserve ResizeObserver on detach (T1311706) (#31515)
1 parent 0af4c49 commit e2cce8d

File tree

4 files changed

+37
-0
lines changed

4 files changed

+37
-0
lines changed

packages/devextreme/js/__internal/ui/chat/messagelist.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,7 @@ class MessageList extends Widget<Properties> {
612612

613613
_clean(): void {
614614
this._lastMessageDate = null;
615+
resizeObserverSingleton.unobserve(this.$element().get(0));
615616

616617
super._clean();
617618
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,6 +1124,11 @@ class Splitter extends CollectionWidgetLiveUpdate<Properties> {
11241124
getLayout(): number[] {
11251125
return this._layout ?? [];
11261126
}
1127+
1128+
_clean(): void {
1129+
resizeObserverSingleton.unobserve(this.$element().get(0));
1130+
super._clean();
1131+
}
11271132
}
11281133

11291134
registerComponent('dxSplitter', Splitter);

packages/devextreme/testing/tests/DevExpress.ui.widgets/chatParts/messageList.tests.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import TypingIndicator from '__internal/ui/chat/typingindicator';
1515
import devices from '__internal/core/m_devices';
1616
import localization from 'localization';
1717
import dateLocalization from 'common/core/localization/date';
18+
import resizeObserverSingleton from 'core/resize_observer';
1819

1920
const CHAT_MESSAGELIST_CONTENT_CLASS = 'dx-chat-messagelist-content';
2021
const CHAT_MESSAGELIST_EMPTY_MESSAGE_CLASS = 'dx-chat-messagelist-empty-message';
@@ -1634,6 +1635,19 @@ QUnit.module('MessageList', () => {
16341635
}
16351636
});
16361637
});
1638+
1639+
QUnit.test('Should unobserve element on detach (T1311706)', function(assert) {
1640+
sinon.stub(resizeObserverSingleton, 'unobserve');
1641+
1642+
const instance = new MessageList($('#component'));
1643+
const $element = $(instance.$element());
1644+
1645+
$element.remove();
1646+
1647+
assert.strictEqual(resizeObserverSingleton.unobserve.callCount, 2);
1648+
1649+
resizeObserverSingleton.unobserve.restore();
1650+
});
16371651
});
16381652

16391653

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import config from 'core/config';
88
import { createEvent } from 'common/core/events/utils/index';
99
import { name as DOUBLE_CLICK_EVENT } from 'common/core/events/double_click';
1010
import { name as CLICK_EVENT } from 'common/core/events/click';
11+
import resizeObserverSingleton from 'core/resize_observer';
1112

1213
import 'generic_light.css!';
1314

@@ -1344,6 +1345,22 @@ QUnit.module('Pane sizing', moduleConfig, () => {
13441345

13451346
this.assertLayout(['0', '66.6677', '33.3339']);
13461347
});
1348+
1349+
QUnit.test('Should unobserve element on detach (T1311706)', function(assert) {
1350+
sinon.stub(resizeObserverSingleton, 'unobserve');
1351+
1352+
const $splitter = $('<div id="splitterDetached">');
1353+
1354+
$splitter.dxSplitter({
1355+
dataSource: [{ size: '30%' }, { size: '70%' }]
1356+
});
1357+
1358+
$splitter.remove();
1359+
1360+
assert.strictEqual(resizeObserverSingleton.unobserve.callCount, 2);
1361+
1362+
resizeObserverSingleton.unobserve.restore();
1363+
});
13471364
});
13481365

13491366
QUnit.module('Pane visibility', moduleConfig, () => {

0 commit comments

Comments
 (0)