-
Notifications
You must be signed in to change notification settings - Fork 36
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
Support ActionMenu having null children #1445
Conversation
Looking good, but can you add a test for the null case ? |
We're thinking about that and it's not impossible that instead of hiding features, we'll simply "disabled them" by displaying them with a special style and removing the onclick action. |
Some will likely stay fully hidden, for example those that we want either in the topbar or in the menu depending on the context.
Yup, done ! |
react/ActionMenu/index.spec.jsx
Outdated
const comp = mount( | ||
<ActionMenu onClose={jest.fn()}> | ||
<ActionMenuItem>Item 1</ActionMenuItem> | ||
null |
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 is a null string here ?
I think you want { null }
.
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.
🤦♂️thanks
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.
Was the testing passing with the "null" string ? If yes, this could be a problem.
react/ActionMenu/index.spec.jsx
Outdated
nodeName: 'BODY', | ||
ownerDocument: document | ||
} | ||
})) |
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.
Why is this needed ?
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.
We have issue for testing component using Tooltip from MUI. See mui/material-ui#15726 (comment)
jsdom-16 fix the issue, but we need to use https://www.npmjs.com/package/jest-environment-jsdom-sixteen. I tried few months ago but still the issue. Maybe it's fine now.
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.
AMHA this should not be in this test file and should be called with a name that reviewers can understand.
Tooltip/testing.js or testing.js, something like that:
const fixTooltipTesting = () => {
let createRangeBackup
beforeAll(() => {
createRangeBackup = global.document.createRange
global.document.createRange = jest.fn(() => ({
setStart: () => {},
setEnd: () => {},
commonAncestorContainer: {
nodeName: 'BODY',
ownerDocument: document
}
}))
afterAll(() => {
global.document.createRange = createRangeBackup
})
}
This way we do not need a comment, it's clearer for the reviewer.
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.
and we can import it from other libs 👍
👍 |
generated from commit 63e20d2
🎉 This PR is included in version 35.11.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
In Drive we have an ActionMenu but not all items are visible at all time — if one of the items should be hidden, it returns null instead, as is common in React. This was breaking
ActionMenu
because it was checkingnull.type
.I also added an example for the
right
prop of ActionMenuItem so that we have visual regression tests for it.