question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DateInput or ArrayInput with warnWhenUnsavedChanges are triggering an alert when submitting the form

See original GitHub issue

Hello!

What you were expecting: I’m using the warnWhenUnsavedChanges option on my TabbedForm, it was working as expected until I add a DateInput in my form. When I update my date in the form, I don’t want to have the “unsaved” alert when I’m submitting my changes.

What happened instead:

  • When I change the date in my form, I have the “unsaved” alert when I submit the form.
  • When I change other fields (and not the date), I don’t have the issue.
  • When I confirm the alert, the submit is working, my date is correctly saved.
  • It seems to be the same issue with DateTimeInput.

Steps to reproduce: Using the option warnWhenUnsavedChanges in a TabbedForm, with a DateInput inside it.

Related code: I don’t have much code to show, the components are a bit split:

export const UnitCreate: FC = (props: any) => (
  <Create {...props} undoable={0}>
    <TabbedForm warnWhenUnsavedChanges>
      <MainFormTab />
      <TermsFormTab />
    </TabbedForm>
  </Create>
);
export const MainFormTab: FC<MainFormTabProps> = (props: any) => {
  return (
    <GenericMainFormTab {...props} hideDefaultField>
      <TextInput
        disabled={props.disabled}
        fullWidth
        label="resources.unit.title"
        source="title"
        validate={[required()]}
      />
      <DateInput
        disabled={props.disabled}
        label="resources.unit.rightsEndDate"
        source="rightsEndDate"
      />
    </GenericMainFormTab>
  );
};

ezgif-3-3152748be90c

Environment

  • React-admin version: 3.8.4
  • React version: 16.13.1
  • Browser: Chrome 85

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
djhicommented, Jan 15, 2021

See #5776 which should be released in next patch version

2reactions
lilit-melkonyan-imcommented, Jan 15, 2021

I have the same issue after updating the react-admin version from 3.8.2 to 3.11.2. It works for some FormWithRedirect forms and doesn’t work for TabbedForms at all. Any news??

Read more comments on GitHub >

github_iconTop Results From Across the Web

DateInput or ArrayInput with warnWhenUnsavedChanges are ...
DateInput or ArrayInput with warnWhenUnsavedChanges are triggering an alert when submitting the form.
Read more >
trigger an browser alert when submitting a form - Stack Overflow
im trying to let the user know that he submitted his form by a simple alert, but somehow this leads to not working....
Read more >
React-admin - The Create and Edit Views
Warning about unsaved changes is an opt-in feature: you must set the warnWhenUnsavedChanges prop in the form component to enable it: export const...
Read more >
Trigger a button click and generate alert on form submission in ...
Trigger a button click and generate alert on form submission in JavaScript - Let's say the following is our button − Submit O...
Read more >
react-admin: Versions | Openbase
Fix <ArrayInput> throws an error when providing a helperText (#8276) (slax57) ... Fix null values cause warning in forms (#8212) (fzaninotto) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found