React-day-picker: Add support for disabled inputs

Created on 29 Mar 2018  路  4Comments  路  Source: gpbl/react-day-picker

I want to disable DayPickerInput, when I'll get date from API, or whatever.
I didn't find anything about my issue in docs.

inputProps={{disabled: true, readOnly: true }}

works, but not so well, whatever I can click on input, end dayPicker will appear, and I'll be able to change date as normal...

good first issue

Most helpful comment

The support for disabled inputs is on v7.1.6

All 4 comments

DayPickerInput does not take in disabled prop. You could use input box to get past this issue:
disabled ? <input value={}> : <DayPickerInput/>

Hello! I added disabling this way:

import DayPickerInput from 'react-day-picker/DayPickerInput';
import cn from 'classnames';

<DayPickerInput
    inputProps={{
      className: cn(
        'ant-input',
        className,
        {
          'ant-input-disabled': disabled
        }
      ),
      disabled: disabled
    }}
/>

@Meloman4eg adding a className shouldn't solve this issue, as the overlay will appear on click even if the field is marked as disabled. I think I should check the inputProps and disable the click event there.

The support for disabled inputs is on v7.1.6

Was this page helpful?
0 / 5 - 0 ratings