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

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/react/src/components/OverflowMenu/OverflowMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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?

handleOverflowMenuItemFocus: this.handleOverflowMenuItemFocus,
ref: (e) => {
this[`overflowMenuItem${index}`] = e;
Expand Down