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

refactor(ui5-menu): remove references to parent #11217

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

Conversation

didip1000
Copy link
Contributor

@didip1000 didip1000 commented Mar 31, 2025

Refactored submenu closing and navigation handling, removing references to the parent element:

  • MenuItems now close their own submenus when necessary.
  • Exiting end content navigation with the up/down arrow keys with throw an exit-end-content event, which is handled by the parent Menu or MenuItem.
  • Fixed an issue with menu item navigation when holding down space on a menu item with a submenu.

@didip1000 didip1000 self-assigned this Mar 31, 2025
@didip1000 didip1000 requested a review from hinzzx March 31, 2025 07:05
@@ -46,7 +46,7 @@ function rightContent(this: MenuItem) {
</div>
);
case this.hasEndContent:
return <slot name="endContent"></slot>;
return <slot name="endContent" onKeyDown={this._endContentKeyDown}></slot>;
Copy link
Contributor

@hinzzx hinzzx Apr 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im not sure if handling events is a good practice on slot level, maybe wrap it in <div> and handle the event from there.

@tsanislavgatev could you give your opinion on this, as I am not entirely sure.

Copy link
Contributor Author

@didip1000 didip1000 Apr 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The solution was discussed with Tsani, but he could have had something else in mind :)

Putting it in a div causes styling issues and potentially other issues I can't think of right now.

this._closeItemSubMenu(openedSibling);
const menuItems = this._menuItems;
if (menuItems.indexOf(item) > -1) {
menuItems.forEach(menuItem => { menuItem !== item && menuItem._close(); });
Copy link
Contributor

@hinzzx hinzzx Apr 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is hard to read. We have a convention to keep the && operator for boolean checks only and not chain it with method calls.

Even though it would be a little bit longer code wise, please use if.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took out the logic in a function instead, but the naming could probably be improved (_closeOtherSubMenus)

I'm hesitant on calling it _closeSiblingSubMenus

@didip1000 didip1000 requested a review from hinzzx April 9, 2025 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants