Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render MenuItem without item or submenu #989

Merged
merged 3 commits into from
Sep 3, 2024
Merged

Conversation

ignas-k
Copy link
Contributor

@ignas-k ignas-k commented Aug 29, 2024

Changes

In #875 the item prop of CursorMenuItemProps was deprecated and replacement props added. However, MenuItemHelpers.createMenuItemNode was still checking if the MenuItem had item or submenu. Using the new props this condition would fail and the function would return null instead of a component node.

I changed the function to render ContextMenuItem by default (without any condition) so this does change the behaviour slightly. Before if the actionItem or submenu was not set it would return null but now it will return a normal node. I believe this is fine because MenuItem constructor already has a check that at least one of item, submenu or execute prop has to be used or it throws an error. So technically it should not even be possible to pass MenuItem without required properties to the MenuItemHelpers.createMenuItemNode function.

Fixes #984.

Testing

Added a test and changed component examples to adjust for the deprecation.

@ignas-k ignas-k self-assigned this Aug 29, 2024
@ignas-k ignas-k requested a review from a team as a code owner August 29, 2024 06:02
@GerardasB GerardasB merged commit 71f2d73 into master Sep 3, 2024
20 checks passed
@GerardasB GerardasB deleted the fix-menu-item-rendering branch September 3, 2024 07:10
@GerardasB
Copy link
Collaborator

@Mergifyio backport release/4.16.x

Copy link
Contributor

mergify bot commented Sep 3, 2024

backport release/4.16.x

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Sep 3, 2024
* Render MenuItem without item or submenu

* Add test

* Update changelog

(cherry picked from commit 71f2d73)

# Conflicts:
#	docs/changehistory/NextVersion.md
GerardasB added a commit that referenced this pull request Sep 3, 2024
* Render `MenuItem` without `item` or `submenu` (#989)

* Render MenuItem without item or submenu

* Add test

* Update changelog

(cherry picked from commit 71f2d73)

# Conflicts:
#	docs/changehistory/NextVersion.md

* Remove NextVersion.md changes

---------

Co-authored-by: Ignas Kasinskas <138560995+ignas-k@users.noreply.github.com>
Co-authored-by: GerardasB <10091419+GerardasB@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants