-
-
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
Use resource definition to set default <Datagrid rowClick>
value
#9466
Conversation
@@ -604,7 +592,7 @@ But now that the `users` resource has a `show` view, you can also link to it fro | |||
// in src/posts.tsx | |||
export const PostList = () => ( | |||
<List> | |||
<Datagrid rowClick="edit"> | |||
<Datagrid> | |||
- <ReferenceField source="userId" reference="users" /> | |||
+ <ReferenceField source="userId" reference="users" link="show" /> |
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.
Not for this PR but this should probably be automatic as well (detection of the available views with the same priorities)
@@ -93,7 +91,7 @@ const ListViewGuesser = ( | |||
); | |||
const inferredChild = new InferredElement( | |||
listFieldTypes.table, | |||
{ hasEdit, hasShow }, |
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 ?
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.
because it's no longer necessary 🤷
(ListGuesser
used these props to calculate the rowClick
prop, which we no longer needed, so might as well cleanup the props we send to InferredElement
... Using null
is something I saw in other components (EditGuesser
if my recollection is correct) so I did the same thing)
<Datagrid>
should be smarter than havingrowClick
default tofalse
.It can use the resource definition to look for an existing Show or Edit view, and default to those instead.
This PR changes the default value to be a bit smarter.
Minor Breaking Change
<Datagrid>
will now make the rows clickable as soon as a Show or Edit view is declared on the resource.If you previously relied on the fact that the rows were not clickable by default, you now need to explicitly disable the
rowClick
feature: