React-admin: SimpleForm validation hiding fast

Created on 16 Jan 2020  路  3Comments  路  Source: marmelab/react-admin

I am facing something weird with validation notification if you have a SimpleForm alone (without a Create or Edit tag).

What you were expecting:
See validation message "The form is not valid. Please check for errors" normally a few seconds and then disappear.

What happened instead:
Validation is disappearing so fast, RA/HIDE_NOTIFICATION is firing right after RA/SHOW_NOTIFICATION. If you keep pressed Save button RA/HIDE_NOTIFICATION is not firing, also if you mouseUp outside of Save button (very weird)

Steps to reproduce:
Add a SimpleForm without Create or Edit tag as parent. hit Save button with a required field

Related code:
https://codesandbox.io/s/simple-form-validation-notification-hide-fast-wd8b8
(live app: https://wd8b8.csb.app/#/posts/create, PostCreate.js file, just removed Create tag), go to post create page and hit save a few times.

Also here is the video to see what's happening: https://drive.google.com/open?id=1GprIEnz1YSRD_PiUpys13XBcHcHP9gv2

Environment

  • React-admin version: v3.1.2
  • Last version that did not exhibit the issue (if applicable):
  • React version: v16.12.0
  • Browser: Firefox developer edition 73.0b2 (64-bit) // Google Chrome 79.0.3945.117 (Official Build) (64-bit)
  • Stack trace (in case of a JS error): No error

Most helpful comment

@fzaninotto
I am getting the same behaviour with v3.1.2. I can reproduce the bug with a simplest form:

export const LocationCreate = (props) => (
    <Create {...props}>
        <SimpleForm variant="outlined">
            <TextInput source="code" validate={[required()]} />
        </SimpleForm>
    </Create>
);

When I click on "Save" just once, the validation triggers and the notification bar disappears instantly. When I double-click on the Save button, the notification bar remains.

All 3 comments

I don't know why you use <SimpleForm> without using <Create>. This is neither documented nor supported.

So I don't consider your problem as a bug, please use react-admin as it's documented.

Hi @fzaninotto, I know this is not documented but I would like to explain why I am using a <SimpleForm> without <Create>, it's because I am creating a custom page with a wizard (onboarding) and it's not a simple CRUD, I am overriding save func in order to save content, it's validating ok, it works ok except for the hide notification which is firing right after show notification.

Thanks!

@fzaninotto
I am getting the same behaviour with v3.1.2. I can reproduce the bug with a simplest form:

export const LocationCreate = (props) => (
    <Create {...props}>
        <SimpleForm variant="outlined">
            <TextInput source="code" validate={[required()]} />
        </SimpleForm>
    </Create>
);

When I click on "Save" just once, the validation triggers and the notification bar disappears instantly. When I double-click on the Save button, the notification bar remains.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alukito picture alukito  路  3Comments

mbj36 picture mbj36  路  3Comments

aserrallerios picture aserrallerios  路  3Comments

Dragomir-Ivanov picture Dragomir-Ivanov  路  3Comments

phacks picture phacks  路  3Comments