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 disabled behavior inconsistent with custom toolbar documentation #5220

Closed
sebitoelcheater opened this issue Sep 1, 2020 · 2 comments · Fixed by #5285
Closed

Comments

@sebitoelcheater
Copy link

What you were expecting:
After I use a custom toolbar in an Edit component , the save button should keep disabled until the form has any modifications or it's dirty.

What happened instead:
The save button keeps enabled.

Steps to reproduce:

const CustomToolbar = props => (
  <Toolbar {...props} >
    <SaveButton/>
  </Toolbar>
);

export default props => (
  <Edit undoable={false} {...props} initialValues={{"company.avatar.original": ''}}>
    <TabbedForm redirect={"edit"} toolbar={<CustomToolbar/>}>
      <FormTab redirect={"edit"} label="Personal data">
        <TextInput source="first_name"/>
      </FormTab>
    </TabbedForm>
  </Edit>
);

Environment

  • React-admin version: ^3.7.1
  • Last version that did not exhibit the issue (if applicable):
  • React version: ^16.13.1
  • Browser: chrome
  • Stack trace (in case of a JS error):
@djhi
Copy link
Collaborator

djhi commented Sep 2, 2020

Thanks for reporting this. If you are able to illustrate the bug or feature request with an example, please provide a sample application by forking the following CodeSandbox (https://codesandbox.io/s/github/marmelab/react-admin/tree/master/examples/simple).

@wattry
Copy link

wattry commented Sep 15, 2020

We have noticed this too. I'd rephrase the issue as such: "SaveButton disabled behavior inconsistent with custom toolbar documentation". In the documentation it is states

By default the <SaveButton> is disabled when the form is pristine..

When using a custom Toolbar and react-admin out of the box, the save button does not seem to follow the example provided in the codesandbox.

Here is an example: https://codesandbox.io/s/polished-sun-xqkcm?file=/src/Posts.js

@sebitoelcheater sebitoelcheater changed the title Save button does keeps enabled even if form is not dirty when using custom toolbar on edit Save button keeps enabled even if form is not dirty when using custom toolbar on edit Sep 15, 2020
@sebitoelcheater sebitoelcheater changed the title Save button keeps enabled even if form is not dirty when using custom toolbar on edit SaveButton disabled behavior inconsistent with custom toolbar documentation Sep 15, 2020
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.

4 participants