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

Unable to clear default value in DateTimeInput component #9703

Open
uniquelau opened this issue Mar 6, 2024 · 3 comments
Open

Unable to clear default value in DateTimeInput component #9703

uniquelau opened this issue Mar 6, 2024 · 3 comments

Comments

@uniquelau
Copy link

uniquelau commented Mar 6, 2024

What you were expecting:
Ability to clear default value from <DateTimeInput />

image

What happened instead:
Default value is set back into the input immediately. The user unable to clear default value.

Steps to reproduce:
Issue only present in v4.16.12, rolled back to v4.16.11 and issue no longer present.
No other code changes have been made reverted or made.

Related code:
The code where this was observed in within a form. It calls a sub component that wraps two inputs and very loosely couples them together.

<>
     <DateTimeInput
        source={startSource}
        defaultValue={defaultStartDate}
      />
      <DateTimeInput
        source={endSource}
        defaultValue={
          addMinutes(defaultEndDate, endDateAddMinutes) ?? defaultEndDate
        }
        validate={invalidDateRange(
          getValues(startSource),
          getValues(endSource),
        )}
      />
</>

Other information:
I'm happy to make a proper repro, but won't have time until the weekend as flat out at the moment.
Thought I'd flag this quickly though, as they release just came out.

Environment

  • React-admin version: v4.16.12
  • Last version that did not exhibit the issue (if applicable): v4.16.11
  • React version: v18.2.x
  • Browser: Firefox
@erwanMarmelab
Copy link
Contributor

Thanks for the quick catch, bug reproduced 👍

@erwanMarmelab
Copy link
Contributor

Update: My bad, we can't reproduce this bug. Please provide a reproduction based on the simple example Codesandbox (https://codesandbox.io/s/github/marmelab/react-admin/tree/master/examples/simple) or on the Storybook (https://react-admin-storybook.vercel.app/?path=/story/ra-ui-materialui-input-dateinput--basic)

@uniquelau
Copy link
Author

Thanks for looking, I will try and reproduce again, and then attempt to create a repro in the sandbox and update you. 👍

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

No branches or pull requests

2 participants