-
Notifications
You must be signed in to change notification settings - Fork 187
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
base: master
Are you sure you want to change the base?
Conversation
so it makes it possible to access popupProps and call methods from it, e.g. onCloseAttempt
a1bb3ae
to
8f5d6e0
Compare
@@ -67,23 +72,52 @@ function DropdownAnchorWrapper({ | |||
return <div {...anchorAriaProps}>{anchor}</div>; | |||
} | |||
|
|||
function renderDropdownMenuChildren<T>({children, popupMenuProps}: DropdownMenuChildren<T>) { | |||
const {data, ...restPopupMenuProps} = popupMenuProps; |
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 exclude data?
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.
otherwise we overwrite data
provided to PopupMenu
. Do you suggest excluding data
from props on a consumer's level?
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 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
So it makes it possible to access
popupProps
and call methods from it, e.g.onCloseAttempt
.Case: when one renders
DropdownMenu
inside of aDropdownMenu
and wants to close the parentDropdownMenu
on the children's select. Otherwise consumer have to stop event propagation on the wrapper level, and create hackish solutions such asDropdownMenu
key re-generation ononSelect
calls. Example in story.