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

RG-2525 feat(DropdownMenu): accept children #8039

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

skoch13
Copy link
Collaborator

@skoch13 skoch13 commented Dec 16, 2024

So it makes it possible to access popupProps and call methods from it, e.g. onCloseAttempt.

Case: when one renders DropdownMenu inside of a DropdownMenu and wants to close the parent DropdownMenu on the children's select. Otherwise consumer have to stop event propagation on the wrapper level, and create hackish solutions such as DropdownMenu key re-generation on onSelect calls. Example in story.

src/dropdown-menu/dropdown-menu.tsx Outdated Show resolved Hide resolved
so it makes it possible to access popupProps and call methods from it,
e.g. onCloseAttempt
@skoch13 skoch13 force-pushed the sk/accept-children-by-dropdown-menu branch from a1bb3ae to 8f5d6e0 Compare December 16, 2024 15:58
@@ -67,23 +72,52 @@ function DropdownAnchorWrapper({
return <div {...anchorAriaProps}>{anchor}</div>;
}

function renderDropdownMenuChildren<T>({children, popupMenuProps}: DropdownMenuChildren<T>) {
const {data, ...restPopupMenuProps} = popupMenuProps;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why exclude data?

Copy link
Collaborator Author

@skoch13 skoch13 Dec 16, 2024

Choose a reason for hiding this comment

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

otherwise we overwrite data provided to PopupMenu. Do you suggest excluding data from props on a consumer's level?

Copy link
Contributor

Choose a reason for hiding this comment

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

If user provides data directly to DropdownMenu we shouldn't just ignore it.

we overwrite data provided to PopupMenu

We don't overwrite anything if children is a function. If it's a React element, you can prevent cloneElement resetting data to undefined by checking that it's not undefined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants