iTwin / appui

Monorepo for iTwin.js AppUi
MIT License
8 stars 2 forks source link

`CursorMenuItemProps` alternative for the deprecation of `item?: CommandItemProps;` not working with `UiFramework.openCursorMenu` #984

Closed jason-crow closed 1 week ago

jason-crow commented 2 weeks ago

Describe the bug

After updating our usage of CursorMenuItemProps to no longer reference the deprecated item?: CommandItemProps; we are finding that the UiFramework.openCursorMenu fails to render the items. We took the advise of the comment above the deprecated field which reads Use properties of this object instead.; however, despite moving the label, icon and execute properties to be inline with the rest of the CurosrMenuItemProps the issue persists.

From debugging the issue, it appears that the MenuItem class that is leveraged to produce the menu items that UiFramework.openCursorMenu uses does not have logic to find the label, iconSpec, badgeType, badgeKind, and isDisabled unless the props can be found on the item field that is deprecated see https://github.com/iTwin/appui/blob/b6a5e1810fc9c23327dfb348df5383e7f9ef8e74/ui/appui-react/src/appui-react/shared/MenuItem.tsx#L126

To Reproduce

  1. have a viewer instance running that is at least on appui v4.15 with a menu built from CursorMenuItemProps where the item field has been replaced by merging its props into the object itself.
  2. have a way to visualize these menu items by passing them to UiFramework.openCursorMenu
  3. notice that the menu items do not appear and only a thin vertical line where the menu would otherwise be shown is visible

Expected Behavior

The expectation is that the menu shows exactly the same as it does when the CommandItemProps are on the item field instead of merged inline with the rest of the CursorMenuItemProps

Screenshots

Before: image

After: image

Desktop (please complete the applicable information)

Additional context

No response