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

meta is undefined in params of delete method of dataProvider when using DeleteButton #8016

Closed
carlos-duran opened this issue Jul 27, 2022 · 1 comment · Fixed by #8023
Closed
Assignees
Labels

Comments

@carlos-duran
Copy link
Contributor

carlos-duran commented Jul 27, 2022

What you were expecting:

Receiving meta in data provider when using DeleteButton with mutationOptions prop.

What happened instead:

meta is undefined in the delete method of dataProvider.

Steps to reproduce:

  1. Open my fork of code sandbox, logout and login with "user" and "password"
  2. Navigate to Users, pick one and enter to Edit page
  3. Click on the Delete button
  4. Check the console

Related code:

https://codesandbox.io/s/young-pond-nioyun?file=/src/users/UserEdit.tsx:613-683

// UserEdit.tsx line 34
<DeleteWithConfirmButton mutationOptions={{ meta: { foo: "bar" } }} />
// dataProvider.tsx line 47
delete: (resource, params) => {
    // HERE
    console.log("No meta :(", { params });
    return dataProvider.delete(resource, params);
  }

Other information:

image
image

Suggestion to possible fix:
https://github.com/marmelab/react-admin/blob/master/packages/ra-core/src/controller/button/useDeleteWithConfirmController.tsx#L98

// ra-core/src/controller/button/useDeleteWithConfirmController.tsx line 98
// ra-core/src/controller/button/useDeleteWithUndoController.tsx line 66

// from
{ id: record.id, previousData: record }
// to
{ id: record.id, previousData: record, meta: mutationOptions.meta }

image

Environment

  • React-admin version: 4.2.4
  • Last version that did not exhibit the issue (if applicable):
  • React version: 17
  • Browser: Chrome 100+
  • Stack trace (in case of a JS error):
@carlos-duran carlos-duran changed the title meta is undefined in params of delete method of dataProvider when using Deletebutton meta is undefined in params of delete method of dataProvider when using DeleteButton Jul 27, 2022
@antoinefricker antoinefricker self-assigned this Jul 29, 2022
@antoinefricker antoinefricker added this to the 4.2.6 milestone Jul 29, 2022
@antoinefricker antoinefricker removed this from the 4.2.6 milestone Jul 29, 2022
@antoinefricker
Copy link
Contributor

Bug reproduced - thank you for your report and the fix, it allowed a wider check of meta support.

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

Successfully merging a pull request may close this issue.

2 participants