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

v4.0 Inconsistent mutationMode usage between Create and Edit components #7528

Closed
panfiva opened this issue Apr 12, 2022 · 3 comments · Fixed by #7533
Closed

v4.0 Inconsistent mutationMode usage between Create and Edit components #7528

panfiva opened this issue Apr 12, 2022 · 3 comments · Fixed by #7533
Labels

Comments

@panfiva
Copy link

panfiva commented Apr 12, 2022

Is your feature request related to a problem? Please describe.
Currently, mutationMode attribute is available in Edit component, but not available in Create component

In order to specify mutation mode in Create component, I have to use mutationMode property of Form component, however it has 2 issues:

  • It is undocumented in React-Admin
  • It only works with Create components; and does not work with Edit components
export const CreateForm= (props: CreateProps) => {
	return (
		<Create {...props} redirect='list'>
			<Form mutationMode='pessimistic' toolbar={<CustomToolbar />} />
		</Create>
	)
}

export const EditForm= (props: EditProps) => {
	return (
		<Edit {...props} redirect='list' mutationMode='pessimistic'>
			<Form toolbar={<CustomToolbar />} />
		</Edit>
	)
}

Describe the solution you'd like

  • I would like mutation mode to be consistently used in both Create and Edit components.
  • I also would like to remove mutationMode property from Form component properties (from SimpleFormProps) so that typescript will not offer it as an option
@fzaninotto
Copy link
Member

No mutationMode other than pessimistic is allowed in the Create view by design. Or, to put it otherwise, optimistic creations aren't supported (because the client-side often doesn't have the sequence required to create an identifier)

So Create doesn't need to support a mutationMode prop.

@panfiva
Copy link
Author

panfiva commented Apr 12, 2022

Since mutationMode is not supported, can we remove fmutationMode from SimpleFormProps so that typescript does not offer it as an option?

@fzaninotto
Copy link
Member

You're right, the type is wrong. I'm reopening this and marking it as a bug.

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.

3 participants