What Changed
In previous versions, our Context Menu component renders items in the component's parent element in the DOM tree:
HTML<body>
<!-- ... -->
<!-- Сontainer that invokes the Context Menu -->
<div class="component-container">
<div class="dxbs-preventsel target-container">...</div>
<!-- DxContextMenu -->
<ul class="dx-blazor-context-menu">
<!-- DxContextMenuItem -->
<li>
<div class="dx-blazor-context-menu-item">
<!-- ... -->
</div>
</li>
<!-- ... -->
</ul>
</div>
</body>
In v22.1, the Context Menu uses the DevExpress DropDown component for Blazor to display items. Due to this change, items are rendered as follows:
HTML<body>
<!-- ... -->
<!-- Сontainer that invokes the Context Menu -->
<div class="component-container">
<div class="dxbs-preventsel target-container">...
<!-- Context Menu -->
<dxbl-popup-portal>...</dxbl-popup-portal>
</div>
</div>
<!-- ... -->
<!-- Context Menu -->
<dxbl-popup-root>
<dxbl-popup-cell>
<dxbl-dropdown>
<dxbl-dropdown-dialog>
<div>
<!-- Context Menu items -->
</div>
</dxbl-dropdown-dialog>
</dxbl-dropdown>
</dxbl-popup-cell>
<!-- SubMenu -->
<dxbl-popup-cell>
<dxbl-dropdown>
<dxbl-dropdown-dialog>
<div>
<!-- SubMenu items -->
</div>
</dxbl-dropdown-dialog>
</dxbl-dropdown>
</dxbl-popup-cell>
</dxbl-popup-root>
</body>
Reasons for Change
Previously, specific CSS properties applied to the parent element of the Context Menu might clip or corrupt the item's content (for instance, if users set the overflow
property to hidden
or scroll
). We changed how the component is rendered to avoid such side effects.
Impact on Existing Apps
This change affects applications with Context Menu if you apply a CSS selector that relies on the component's position in the DOM tree.
How to Update Existing Apps
Update CSS selectors to take into account the new position of Context Menu and its items in the DOM tree. You can also use the CssClass
property for the Context Menu and CssClass
and SubMenuCssClass
properties for the Context Menu items as follows:
Razor<DxContextMenu CssClass="my-context-menu-style">
<Items>
<DxContextMenuItem Text="Name" CssClass="my-item-style" SubMenuCssClass="my-submenu-style">
<Items>
@* ... *@
</Items>
</DxContextMenuItem>
@* ... *@
</Items>
</DxContextMenu>