-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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 custom actions cannot override basePath #3043
Conversation
Previously, it was impossible to write: `<Show basePath="/foo" actions={<ShowActions basePath="/foo/bar" />} />` because we were not tolerating `props` on `DefaultActions`, making the API/props useless/broken.
So far, it was not possible to edit the DefaultActions props due to this missing spread
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.
Extract from react doc:
Clone and return a new React element using element as the starting point. The resulting element will have the original element’s props with the new props merged in shallowly
I'm quite sure this is not needed.
Indeed, it is.
It's easy to setup a test. I hit the bug and already verified, It won't break, because, by default, none of the This was my use case, I have a custom route with path import React from 'react';
import WithPermissions from 'ra-core/lib/auth/WithPermissions';
import ShowActions from 'ra-ui-materialui/lib/detail/ShowActions';
import ProjectServiceNewsletterContactShowDefault from '../../resources/contacts/ProjectServiceNewsletterContactShow';
function ProjectServiceNewsletterContactShow({ roles, match, staticContext, ...rest }) {
return (
<WithPermissions
render={({ permissions }) => (
<ProjectServiceNewsletterContactShowDefault
actions={<ShowActions basePath={"/newsletter/groups/contacts"} />}
hasEdit={permissions.includes(roles.PROJECT_EDIT)}
id={match.params.id}
basePath={match.url}
resource={"newsletter/groups/contacts"}
{...rest}
/>
)}
/>
);
}
export default ProjectServiceNewsletterContactShow; |
cloneElement was setting props, and no spread applied after that, was making impossible to modify them marmelab/react-admin#3043
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 in advance for review
Ah I see. Fair point! |
There are probably many places where this should be done too |
Thanks! |
Previously, it was impossible to write:
<Show basePath="/foo" actions={<ShowActions basePath="/foo/bar" />} />
because we were not toleratingprops
onDefaultActions
, making the API/props useless/broken.