Closed dogle-scottlogic closed 7 months ago
Hello,
This is currently being worked on. It has exposed some flakiness in how we handle disabled dates, and we'll be refactoring how they work. We expect this to be released by 22 November 2023.
This is an accessibility improvement. Disabled dates will not be selectable, but being able to move through disabled dates will be less jarring for a non-sighted user who might in the current date picker be jumped over a set of disabled dates with no explanation of why. Disabled dates will use aria-disabled="true"
to flag this status for assistive tech.
This will address your use case where you want to be able to show a user an entire unavailable month ("...so that we can always navigate back one month")
A selection of 31 Jan will no longer skip over the entirety of February
This alteration to how the date picker works has been released in v1.2.0
Issue resolved.
Description of the issue
We have a requirement to set the minDate for the date picker to the last day of the previous month so that we can always navigate back one month. When we do this the navigation for months skips out the current month (See steps below).
Steps to reproduce the issue
For all steps the following variables remain constant:
this.maxDate
is 08/Dec/2023this.minDate
is 31/Oct/2023this.disabledDates
is ['10/31/2023', '11/1/2023', '11/2/2023', '11/3/2023', '11/4/2023', '11/5/2023', '11/6/2023', '11/7/2023', '11/8/2023', '11/11/2023', '11/12/2023', '11/18/2023', '11/19/2023', '11/25/2023', '11/26/2023', '12/2/2023', '12/3/2023']Steps:
this.currentDate
is 07/Nov/2023this.currentDate
is 07/Dec/2023this.currentDate
is 31/Oct/2023this.currentDate
is 01/Dec/2023Expected behaviour
Rather than Nov -> Dec <- Oct -> Dec the navigation should be Nov -> Dec <- Nov -> Dec <- Nov <- Oct -> Nov
From a little digging it seems that what's happening is:
this.currentDate
is 07/Nov/2023this.currentDate
is 07/Dec/2023focusPreviousMonth
callsdate.setMonth(date.getMonth() - 1);
focusPreviousDay
minDate
socurrentDate
is set to 31/Oct/2023Likewise when we step forward again after this point:
date.setMonth(date.getMonth() + 1);
evaluates to 01/Dec/2023 when date is 31/Oct/2023Update: This bug is also partially reproducible in the example Date Picker on the design system website by navigating to 31/01/2024 and then clicking forward a month. Expected behaviour is to be taken to Feb, actual behaviour is you are skipped to March
Screenshots
Environment