Skip to content

Commit

Permalink
ContextMenu: empty shownMenus list on clean (T1257288)
Browse files Browse the repository at this point in the history
  • Loading branch information
anna-shakhova committed Dec 24, 2024
1 parent 4c2eb72 commit 7b78082
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ class ContextMenu extends MenuBase {
this._overlay = null;
}
this._detachShowContextMenuEvents(this._getTarget());
this._shownSubmenus = [];
super._clean();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 7b78082

Please sign in to comment.