From 7b78082bcdfdb698964cbec091c5180e47b996a7 Mon Sep 17 00:00:00 2001 From: "anna.shakhova" Date: Tue, 24 Dec 2024 11:31:41 +0100 Subject: [PATCH] ContextMenu: empty shownMenus list on clean (T1257288) --- .../ui/context_menu/m_context_menu.ts | 1 + .../contextMenu.tests.js | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/packages/devextreme/js/__internal/ui/context_menu/m_context_menu.ts b/packages/devextreme/js/__internal/ui/context_menu/m_context_menu.ts index e05648df237..4dc8a379d73 100644 --- a/packages/devextreme/js/__internal/ui/context_menu/m_context_menu.ts +++ b/packages/devextreme/js/__internal/ui/context_menu/m_context_menu.ts @@ -343,6 +343,7 @@ class ContextMenu extends MenuBase { this._overlay = null; } this._detachShowContextMenuEvents(this._getTarget()); + this._shownSubmenus = []; super._clean(); } diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets/contextMenu.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets/contextMenu.tests.js index 72e8890f6bc..e69cec10fa2 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets/contextMenu.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets/contextMenu.tests.js @@ -273,6 +273,37 @@ QUnit.module('Rendering', moduleConfig, () => { }); }); +QUnit.module('Repaint', moduleConfig, () => { + QUnit.test('On repaint all submenus should be hidden without console errors (T1257288)', function(assert) { + if(!isDeviceDesktop(assert)) { + return; + } + + const instance = new ContextMenu(this.$element, { + items: [{ text: 'Item 1', items: [{ text: 'Item 11' }, { text: 'Item 12' }] }], + visible: true, + showSubmenuMode: { name: 'onHover', delay: 0 }, + onItemClick: (e) => e.component.repaint(), + }); + + const $itemsContainer = instance.itemsContainer(); + const $rootItem = $itemsContainer.find(`.${DX_MENU_ITEM_CLASS}`).eq(0); + + $($itemsContainer).trigger($.Event('dxhoverstart', { target: $rootItem.get(0) })); + this.clock.tick(0); + + const $submenus = $(`.${DX_SUBMENU_CLASS}`); + const $nestedSubmenu = $submenus.eq(1); + const $nestedSubmenuItem = $nestedSubmenu.find(`.${DX_MENU_ITEM_CLASS}`).eq(0); + + assert.strictEqual($submenus.length, 2, 'Nested submenu is shown'); + + $($nestedSubmenuItem).trigger('click'); + + assert.ok(true, 'No errors were thrown'); + }); +}); + QUnit.module('Rendering Scrollable', moduleConfig, () => { const DX_SCROLLABLE_CLASS = 'dx-scrollable'; const DX_SCROLLABLE_CONTAINER_CLASS = 'dx-scrollable-container';