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

fix(OverflowMenu): check for custom closeMenu method #7456

Conversation

emyarod
Copy link
Member

@emyarod emyarod commented Dec 14, 2020

Closes #6412

This PR prevents custom closeMenu methods from being overwritten by the default method in order to support a wider range of interactions on the overflow menu

Changelog

Changed

  • check for OverflowMenuItem closeMenu before cloning the element and assigning a default value for the function

Testing / Reviewing

confirm that adding a custom closeMenu method on an OverflowMenuItem will not be overwritten

@netlify
Copy link

netlify bot commented Dec 14, 2020

❌ Deploy preview for carbon-components-react failed.
Built without sensitive environment variables

🔨 Explore the source changes: 15d7140

🔍 Inspect the deploy logs: https://app.netlify.com/sites/carbon-components-react/deploys/60076b24f555ba00077a4ad0

@netlify
Copy link

netlify bot commented Dec 14, 2020

✔️ Deploy preview for carbon-elements ready!

🔨 Explore the source changes: 15d7140

🔍 Inspect the deploy logs: https://app.netlify.com/sites/carbon-elements/deploys/60076b24893dce0007061eab

😎 Browse the preview: https://deploy-preview-7456--carbon-elements.netlify.app

@@ -494,7 +494,7 @@ class OverflowMenu extends Component {
const childrenWithProps = React.Children.toArray(children).map(
(child, index) =>
React.cloneElement(child, {
closeMenu: this.closeMenu,
closeMenu: child.props.closeMenu || this.closeMenu,
Copy link
Contributor

Choose a reason for hiding this comment

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

Would we need to run both functions instead of deferring to a given child closeMenu? Seems like this.closeMenu has some state logic that we want to run but I might be misunderstanding 👀

Copy link
Member Author

Choose a reason for hiding this comment

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

the main intention is to allow a function that is different from or replaces the default closeMenu (without expanding the component API). if the user still wants to run the existing logic they can use the existing onClose prop. maybe it would be more preferable to just add a boolean prop that controls whether or not the menu will close on selection of an item?

@kodiakhq kodiakhq bot merged commit 56bbffe into carbon-design-system:master Jan 19, 2021
@emyarod emyarod deleted the 6412-overflowitem-allow-custom-closemenu branch January 20, 2021 15:23
@emyarod emyarod mentioned this pull request Jan 22, 2021
46 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

If I use Dropddown or ComboBox in TableToolbarMenu, the popup menu will be closed upon selecting an option
3 participants