-
Notifications
You must be signed in to change notification settings - Fork 273
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
base: main
Are you sure you want to change the base?
Conversation
@@ -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>; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
packages/main/src/Menu.ts
Outdated
this._closeItemSubMenu(openedSibling); | ||
const menuItems = this._menuItems; | ||
if (menuItems.indexOf(item) > -1) { | ||
menuItems.forEach(menuItem => { menuItem !== item && menuItem._close(); }); |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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
Refactored submenu closing and navigation handling, removing references to the parent element:
exit-end-content
event, which is handled by the parent Menu or MenuItem.