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

Fix race condition between http error notification and server-side validation error notification #9848

Merged
merged 7 commits into from
May 17, 2024

Conversation

slax57
Copy link
Contributor

@slax57 slax57 commented May 14, 2024

Problem

When validating server side, you can’t provide a global error message and react-admin displays a default non customizable one.

In some cases (depending on the React version) users could use the error's message field to render a custom message in the notification, but due to a race condition between the 2 notifications, it would not always work.

Solution

In useCreateController and useEditController, check if there are validation errors and if we are in pessimistic mode, and don't notify in this case (as it will be done by useNotifyIsFormInvalid).

In useNotifyIsFormInvalid notify with the root.serverError message if available (otherwise fall back to 'ra.message.invalid_form' like currently).

@slax57 slax57 changed the title WIP: disable http error notification for validation error and allow to customize global msg Fix race condition between http error notification and server-side validation error notification May 15, 2024
Copy link
Contributor

@djhi djhi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💪

docs/Validation.md Outdated Show resolved Hide resolved
Co-authored-by: Gildas Garcia <1122076+djhi@users.noreply.github.com>
@djhi djhi merged commit f1ab8e3 into next May 17, 2024
2 checks passed
@djhi djhi deleted the global-form-server-validation-error branch May 17, 2024 15:55
@djhi djhi added this to the 5.0.0 milestone May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants