-
Notifications
You must be signed in to change notification settings - Fork 51
feat(menuItem: add menu prop) #357
Conversation
Codecov Report
@@ Coverage Diff @@
## master #357 +/- ##
=========================================
- Coverage 89.75% 89.56% -0.2%
=========================================
Files 64 64
Lines 1259 1274 +15
Branches 159 189 +30
=========================================
+ Hits 1130 1141 +11
- Misses 126 129 +3
- Partials 3 4 +1
Continue to review full report at Codecov.
|
src/components/Menu/MenuItem.tsx
Outdated
| border: '', | ||
| }, | ||
| }} | ||
| // content={<Menu items={menu.items} type={type} vertical/>} |
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.
Can someone investigate why using this syntax is creating trouble?
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.
which trouble it creates, specifically?
Please, note that when you are using
content={<Menu items={menu.items} type={type} vertical/>}you don't introduce any wrapper for the Popup's content - and it could happen that the content that you are providing unwrapped (by the expression mentioned above) could have z-index value that would prevent it to be shown on top of the page's content. Consider to review this example for the Popup for more details: https://stardust-ui.github.io/react/components/popup#types-popup-content-wrapper-example
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.
Ah, totally missed the z-index. Thanks for pointing it out.
| onClick: (e, itemProps) => { | ||
| const { index } = itemProps | ||
|
|
||
| this.setState(prev => { |
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.
When should we use setState vs. trySetState? Can someone please explain in brief the purpose of trySetState.
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.
lets schedule a short sync for tomorrow, I will explain the concept to you. Before that, please, consider to read about Controlled and Uncontrolled Components, as well as try to make experiments with input component being used in these different modes - note how the value updates for each, when onChange handler is triggered, how value updates in controlled mode.
|
From ARIA point of view, menu and submenu needs to conform to menu design pattern for both DOM structure and keyboard handling. Please go through the design pattern to understand the requirements. This design pattern is done as a dropdown - I suppose you can achieve similar functionality with popups, but that would require testing. Focus trap zone (#239) should help you with focusing the items on open. But in general, you should look at #126 which implements submenu. Was there a reason why you were not able to follow this approach? |
|
@jurokapsiar I did look at #126 before opening this PR. I went ahead with |
|
@gopalgoel19 it is hard to say before all requirements are fully implemented - keyboard navigation is the first step, then once feature complete, we would need to test with screen readers. For positioning, I believe you can use popper.js and computePopupPlacement utility function the same way how popup uses it. Based on previous experience, following ARIA patterns saves us a lot of time. For #126 we even did validation, which you would need to do from scratch when using popup. |
src/components/Menu/Menu.tsx
Outdated
| vertical, | ||
| index, | ||
| active: parseInt(activeIndex, 10) === index, | ||
| submenuOpen: this.state.activeIndex === index ? this.state.submenuOpen : false, |
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.
Always destructure state and pros, see line 150:
const { activeIndex } = this.stateHere you would add the keys you want to use. activeIndex is already destructured in scope, so you can use it directly. submenuOpen needs to be added to the destructured values. Destructuring keeps code clean, but more importantly it also breaks object references.
The requirements and examples for these issues can be found in @jurokapsiar's links above. |
menuItem
menupropAdd a menu prop which has the capability to render submenus.

TODO