react-admin icon indicating copy to clipboard operation
react-admin copied to clipboard

Unable to clear default value in DateTimeInput component

Open uniquelau opened this issue 1 year ago • 3 comments

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

uniquelau avatar Mar 06 '24 14:03 uniquelau

Thanks for the quick catch, bug reproduced :+1:

erwanMarmelab avatar Mar 08 '24 08:03 erwanMarmelab

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)

erwanMarmelab avatar Mar 12 '24 13:03 erwanMarmelab

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

uniquelau avatar Apr 02 '24 14:04 uniquelau

No news for some time, closing.

fzaninotto avatar May 13 '24 11:05 fzaninotto