-
Notifications
You must be signed in to change notification settings - Fork 18
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
[RA-3888] feat(menu): adds menu component based on mui menu #558
[RA-3888] feat(menu): adds menu component based on mui menu #558
Conversation
adds new menu component based on the material ui menu
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.
[] Code review
[x] unit
[x] regression
[] Doc
id="menu" | ||
data-testid="menu" |
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.
If the objective is to do tests, I believe that these props can be removed. Use screen.getByRole('presentation') in the test to get the menu.
id="menu" | |
data-testid="menu" |
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.
Done
id="menu" | ||
data-testid="menu" | ||
theme={materialThemeOverride} | ||
aria-labelledby="button" |
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.
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.
Removed
components/Menu/Menu.jsx
Outdated
const onClickFunc = () => { | ||
const { handleClick } = item; | ||
handleClose(); | ||
handleClick(); | ||
}; |
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 function here causes it to be recalculated every time the list is rendered, which may result in performance losses. What do you think about moving it after the props are destructured?
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.
Done
components/Menu/Menu.jsx
Outdated
/** If true, the component is shown. */ | ||
open: PropTypes.bool, | ||
/** Menu contents, has a content parameter, an id and a handleClick function. */ | ||
items: PropTypes.array, |
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.
What do you think about defining exactly what data format should be in this array and thus avoiding unwanted surprises? For example, if someone passes an object without the "content" prop, our component will break, as we use "content" in the MenuItem.
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.
It is based on the same data format defined in the typescript file here in the component
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.
Done
components/Menu/Menu.unit.test.jsx
Outdated
anchorEl: mockAnchorEl, | ||
handleClose: mockHandleClose, | ||
}); | ||
const menu = queryByTestId('menu'); |
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.
If you followed the suggestion above, getByRole('presentation') should work here and in other cases where getByTestId is used
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.
Done
stories/Menu/Menu.stories.jsx
Outdated
<div> | ||
<Button | ||
id="button" | ||
aria-controls={open ? 'menu' : undefined} |
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.
aria-controls={open ? 'menu' : undefined} | |
aria-controls="presentation" |
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.
Done
stories/Menu/Menu.stories.jsx
Outdated
id="button" | ||
aria-controls={open ? 'menu' : undefined} | ||
aria-haspopup="true" | ||
aria-expanded={open ? 'true' : undefined} |
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.
aria-expanded={open ? 'true' : undefined} | |
aria-expanded={open} |
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.
Done
stories/Menu/Menu.stories.jsx
Outdated
aria-hidden="true" | ||
aria-label="Menu" | ||
role="button" | ||
id="button" | ||
aria-controls={open ? 'menu' : undefined} | ||
aria-haspopup="true" | ||
aria-expanded={open ? 'true' : undefined} | ||
onClick={handleClick} |
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.
Similar situation to that mentioned previously
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.
Done
components/Menu/index.d.ts
Outdated
horizontal: 'left' | 'center' | 'right'; | ||
}; | ||
keepMounted?: boolean; | ||
handleClose?: (event: {}, reason: 'backdropClick' | 'escapeKeyDown') => void; |
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.
handleClose?: (event: {}, reason: 'backdropClick' | 'escapeKeyDown') => void; | |
onClose?: (event: {}, reason: 'backdropClick' | 'escapeKeyDown') => void; |
onClose seems to make more sense for those who use the component
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.
Done
components/Menu/index.d.ts
Outdated
export interface MenuItemProps { | ||
id: string | number; | ||
content: React.ReactNode; | ||
handleClick: Function; |
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.
handleClick: Function; | |
onClick: Function; |
onClick seems to make more sense for those who use the component
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.
I was thinking here and I believe that this prop doesn't even make much sense to stay in the items object. What about including it as a prop (onClick: (item) => {}) of the component instead of placing it inside the object?
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.
I think your suggestion adds a bit more complexity and my implementation with object literals is superior in this case making the code neater for the user to implement
improves types and component readbility by screen readers
improves test by using role instead of id
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.
[] Code
[] Unit
[] Regression
[] Doc
stories/Menu/Menu.stories.jsx
Outdated
<div> | ||
<button | ||
type="button" | ||
aria-labelledby="Menu" |
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 aria-label is defined, aria-labelledby is not necessary as they have the same purpose
aria-labelledby="Menu" |
<Button | ||
aria-controls="presentation" | ||
aria-haspopup="true" | ||
aria-expanded={open} |
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.
aria-expanded={open} | |
aria-expanded={open} | |
aria-label="Menu" |
Co-authored-by: MarcosViniciusPC <[email protected]>
improves aria labels on documentation component
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.
I can't navigate the menu options using tab
Is this the expected behavior?
Also, he regression tests don't contemplate the opened menu options, only the always visible button |
Yes, the material ui menu also doesn't navigate through tab https://mui.com/material-ui/react-menu/#basic-menu |
In the reference, I cna navigate with the arrows up and down, but not in this component. |
navigation issues
I installed the component on talent-selection (talent-selection_app) and noticed some changes @MarcosViniciusPC suggested broke the arrow navigation and also broke other behaviours (like the opening behaviour). So I reverted some changes back to what they were before and now arrow navigation seems to work again (see video evidence). |
Quality Gate passedIssues Measures |
Due to the urgency, we will create a technical debt for us here at ACME to improve these tests in the future. |
How did you do the tests? I tried to simulate the navigation behavior using the arrow keys here and was unable to navigate between items. @alizeleal , confirm to me later if it worked for you. If not, let me know so I can create a task to correct the navigation. |
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.
[x] Code review
[x] Unit
[] Regression
I generated a build locally and installed it in the talent-selection application and tested there. |
It didn't work in the documentation |
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.
Approved with the technical debt for the keyboard navigation and regressive test
🎉 This PR is included in version 9.26.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
🎉 This PR is included in version 10.0.0-beta.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
adds new menu component based on the material ui menu
Description
Adiciona componente Menu baseado no componente do Material UI
https://jirasoftware.catho.com.br/browse/RA-3888
Setup
to view the components behavior, run
yarn storybook
Review guide
-
yarn test:coverage
- first start the storybook for regression tests(and keep it open):
yarn test:regression:storybook
;- then run the regression tests:
yarn test:regression
A11y review
Browsers review