design-system-react icon indicating copy to clipboard operation
design-system-react copied to clipboard

Datepicker should accept minDate, maxDate props

Open anujsingla opened this issue 3 years ago • 3 comments

Datepicker should accept minDate, maxDate props. Currently, we can not set minDate, maxDate value in the props.

minDate - The minimum date that the user can select. It will ensure that no earlier date is selected. maxDate - The maximum date that the user can select. It will ensure that no later date is selected.

Example - https://reactdatepicker.com/#example-specific-date-range

anujsingla avatar Aug 26 '21 08:08 anujsingla

The components are meant to follow the SLDS design patterns according to their website it does not offer such functionality so I am not sure how they proceed with extra features.

abusarah-tech avatar Sep 05 '21 11:09 abusarah-tech

You can use dateDisabled to achieve that. For example the below will disable dates prior to current day, and additionally disable the current day if it's after 4pm:

<Datepicker
  {...props} // etc
  dateDisabled={({ date }) => {
    const now = new Date();
    date.setHours(16, 0, 0, 0);
    return date < now;
  }}
/>

jcro21 avatar Jan 18 '22 09:01 jcro21

This issue has been automatically marked as stale, because it has not had recent activity. It will be closed if no further activity occurs. Maintainers are responsible for tech debt and project health. This is most likely a new components or component feature request. Please submit a pull request for or request feedback on this feature. Thank you.

stale[bot] avatar Apr 18 '22 19:04 stale[bot]