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

SaveButton does not disable and show indeterminate progress while onSubmit function is executing #7821

Closed
mikemcclaran opened this issue Jun 13, 2022 · 1 comment · Fixed by #7860

Comments

@mikemcclaran
Copy link

What you were expecting:

After clicking the save button I was expecting the button to show indeterminate progress and be disabled from subsequent clicks until the onSubmit function execution completes.

What happened instead:

Button remains active while onSubmit function is executing and no indeterminate progress is shown on the button

Steps to reproduce:

Simplest way to see the issue is to make a onSubmit function that takes a bit of time to execute.

Related code:

CodeSandbox of issue using master
CodeSandbox working properly in v3.x

const UserEditForm = ({ permissions, save, ...props }) => {
  function sleep(ms) {
    return new Promise((resolve) => setTimeout(resolve, ms));
  }

  const newSave = async (values) => {
    console.log("before sleep");
    await sleep(5000);
    console.log("after sleep");
  };

  return (
    <TabbedForm
      defaultValue={{ role: "user" }}
      toolbar={<UserEditToolbar />}
      {...props}
      save={newSave}
    >

...

Other information:

Demo of working as expected in v3.x
Demo of incorrect behavior in v4.x

Environment

  • React-admin version: 4.1.3
  • Last version that did not exhibit the issue (if applicable): v3.x
  • React version:
  • Browser:
  • Stack trace (in case of a JS error):
@antoinefricker
Copy link
Contributor

Reproduced. Thanks for reporting this so precisely.

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

Successfully merging a pull request may close this issue.

2 participants