ministryofjustice / moj-frontend

Use the MoJ Design System to design, build, and deliver accessible and consistent services.
https://design-patterns.service.justice.gov.uk/
MIT License
33 stars 21 forks source link

Datepicker: minDate is inclusive, maxDate is exclusive #923

Open chrispymm opened 1 week ago

chrispymm commented 1 week ago

This may not technically be a bug, but it is inconsistent and non-intuitive. The minDate and maxDate options to the datepicker component behave differently.

{{ mojDatePicker({
  id: "date",
  name: "date",
  label: {
      text: "Date"
  },
  hint: { 
    text: "For example, 17/5/2024."
  },
  value: "10/04/2025",
  minDate: "04/04/2025",
  maxDate: "21/4/2025"
}) }}

With the config above setting a mindate of 04/04/2025 and a maxDate of 21/4/2025

It appears from the code in the component that the intention was for the minDate to be exclusive (as it uses < not <=) however a weird quirk of date comparison appears to be causing it to treat the provided minDate as excluded.

This would be a breaking change to fix