Skip to content

Commit ebb3f4a

Browse files
ContextMenu: Fix scrollable container height calculation for theme-less usage (T1258002) (DevExpress#28981)
1 parent 0aab300 commit ebb3f4a

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

packages/devextreme/js/__internal/ui/context_menu/m_context_menu.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ import type { Properties as OverlayProperties } from '@js/ui/overlay';
2828
import type dxOverlay from '@js/ui/overlay';
2929
import Overlay from '@js/ui/overlay/ui.overlay';
3030
import Scrollable from '@js/ui/scroll_view/ui.scrollable';
31-
import { current as currentTheme, isMaterialBased } from '@js/ui/themes';
31+
// @ts-expect-error
32+
import { current as currentTheme, isGeneric } from '@js/ui/themes';
3233
import MenuBase from '@ts/ui/context_menu/m_menu_base';
3334

3435
const DX_MENU_CLASS = 'dx-menu';
@@ -724,7 +725,7 @@ class ContextMenu extends MenuBase {
724725
}
725726

726727
_getSubmenuBorderWidth() {
727-
return isMaterialBased(currentTheme()) ? 0 : BORDER_WIDTH;
728+
return isGeneric(currentTheme()) ? BORDER_WIDTH : 0;
728729
}
729730

730731
_showSubmenu($item: dxElementWrapper): void {

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import contextMenuEvent from 'events/contextmenu';
1111
import holdEvent from 'events/hold';
1212
import { isRenderer } from 'core/utils/type';
1313
import config from 'core/config';
14+
import themes from 'ui/themes';
1415
import keyboardMock from '../../helpers/keyboardMock.js';
1516
import ariaAccessibilityTestHelper from '../../helpers/ariaAccessibilityTestHelper.js';
1617

@@ -271,6 +272,24 @@ QUnit.module('Rendering', moduleConfig, () => {
271272

272273
assert.strictEqual($icon.attr('alt'), 'dxContextMenu item icon');
273274
});
275+
276+
QUnit.test('contextMenu maxHeight should not include border width if no theme is specified (T1258002)', function(assert) {
277+
const stub = sinon.stub(themes, 'current').returns('none');
278+
279+
try {
280+
const contextMenu = new ContextMenu(this.$element, {
281+
items: [{ text: 'Test Item' }],
282+
visible: true
283+
});
284+
285+
const overlayMaxHeight = contextMenu.itemsContainer().css('maxHeight');
286+
const contentHeight = $(`.${DX_CONTEXT_MENU_ITEMS_CONTAINER_CLASS}`).outerHeight();
287+
288+
assert.strictEqual(overlayMaxHeight, `${contentHeight}px`, 'overlay maxHeight does not include border width');
289+
} finally {
290+
stub.restore();
291+
}
292+
});
274293
});
275294

276295
QUnit.module('Repaint', moduleConfig, () => {

0 commit comments

Comments
 (0)