React-datepicker: ReadOnly props is not working

Created on 25 Aug 2018  路  3Comments  路  Source: Hacker0x01/react-datepicker

Expected behavior

I added readOnly props to datePicker component but when I using this props, then the component is not working but if I remove it, it's working.
NOTE: This problem was not available before.

Actual behavior

I should be work with datePicker while it has readOnly props.

Steps to reproduce

wontfix

Most helpful comment

The change in #1419 broke us as well. I'm also in favor of reverting it. Until then, here is our workaround:

const ForceReadOnlyInput = React.forwardRef((props, ref) => (
  <input {...props} ref={ref} readOnly={true} />
));

<ReactDatePicker
  customInput={<ForceReadOnlyInput />}
/>

It would have been nice to just pass customInput={<input readOnly={true} />}, but the library overwrites the attribute during render.

All 3 comments

For some reason this was changed in https://github.com/Hacker0x01/react-datepicker/pull/1419

Here's the solution I came up with: https://github.com/Hacker0x01/react-datepicker/issues/1443#issuecomment-416531351

The change in #1419 broke us as well. I'm also in favor of reverting it. Until then, here is our workaround:

const ForceReadOnlyInput = React.forwardRef((props, ref) => (
  <input {...props} ref={ref} readOnly={true} />
));

<ReactDatePicker
  customInput={<ForceReadOnlyInput />}
/>

It would have been nice to just pass customInput={<input readOnly={true} />}, but the library overwrites the attribute during render.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

evolve2k picture evolve2k  路  3Comments

jjjss94 picture jjjss94  路  3Comments

hoodsy picture hoodsy  路  3Comments

sarav1234 picture sarav1234  路  3Comments

ericreis picture ericreis  路  3Comments