Skip to content

Commit a94d813

Browse files
marker-daomarker dao ®
andauthored
Popup: Replace detach with remove on toolbar element (T1305512) (#30964)
Co-authored-by: marker dao ® <[email protected]>
1 parent 50b7af5 commit a94d813

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

packages/devextreme/js/__internal/ui/popup/m_popup.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,8 @@ class Popup<
520520

521521
this._$topToolbar?.toggleClass(POPUP_HAS_CLOSE_BUTTON_CLASS, this._hasCloseButton());
522522
} else {
523-
this._$topToolbar?.detach();
523+
this._$topToolbar?.remove();
524+
this._$topToolbar = undefined;
524525
}
525526

526527
this._toggleAriaLabel();
@@ -556,7 +557,8 @@ class Popup<
556557
const items = this._getToolbarItems('bottom');
557558

558559
if (!items.length) {
559-
this._$bottomToolbar?.detach();
560+
this._$bottomToolbar?.remove();
561+
this._$bottomToolbar = undefined;
560562
return;
561563
}
562564

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

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ const POPUP_CONTENT_INHERIT_HEIGHT_CLASS = 'dx-popup-inherit-height';
136136
const POPUP_BOTTOM_RIGHT_RESIZE_HANDLE_CLASS = 'dx-resizable-handle-corner-bottom-right';
137137
const POPUP_TOP_LEFT_RESIZE_HANDLE_CLASS = 'dx-resizable-handle-corner-top-left';
138138
const DISABLED_STATE_CLASS = 'dx-state-disabled';
139+
const TOOLBAR_ITEM_CONTENT_CLASS = 'dx-toolbar-item-content';
139140

140141
const POPUP_DRAGGABLE_CLASS = 'dx-popup-draggable';
141142

@@ -2722,7 +2723,6 @@ QUnit.module('rendering', {
27222723
});
27232724
});
27242725

2725-
27262726
QUnit.test('dx-popup-fullscreen-width class should be attached when width is equal to screen width', function(assert) {
27272727
this.instance.option('width', function() { return getWidth($(window)); });
27282728
this.instance.show();
@@ -2748,6 +2748,39 @@ QUnit.module('rendering', {
27482748
assert.ok($('.' + POPUP_BOTTOM_CLASS).dxToolbar('instance').option('compactMode'), 'bottom toolbar has the compact option');
27492749
});
27502750

2751+
['top', 'bottom'].forEach((position) => {
2752+
QUnit.test(`${position} toolbar should be rendered correctly after clearing the toolbarItems (T1305512)`, function(assert) {
2753+
const popup = $('#popup').dxPopup({
2754+
showCloseButton: false,
2755+
showTitle: false,
2756+
}).dxPopup('instance');
2757+
2758+
popup.option({
2759+
toolbarItems: [
2760+
{
2761+
text: 'first',
2762+
toolbar: position,
2763+
},
2764+
],
2765+
});
2766+
popup.option({ toolbarItems: [] });
2767+
popup.option({
2768+
toolbarItems: [
2769+
{
2770+
text: 'second',
2771+
toolbar: position,
2772+
},
2773+
],
2774+
});
2775+
2776+
popup.show();
2777+
2778+
const $toolbarItemContent = popup.$wrapper().find(`.${TOOLBAR_ITEM_CONTENT_CLASS}`);
2779+
2780+
assert.strictEqual($toolbarItemContent.text(), 'second', 'toolbar with the correct element rendered after toolbarItems cleaning');
2781+
});
2782+
});
2783+
27512784
QUnit.test('dx-popup-content-scrollable class should be attached when preventScrollEvents is used', function(assert) {
27522785
this.instance.show();
27532786

0 commit comments

Comments
 (0)