From f05332a75d430c3b8899c5e4efad56e1d534bf33 Mon Sep 17 00:00:00 2001 From: Mathieu Suen Date: Thu, 2 Nov 2023 11:53:25 +0100 Subject: [PATCH] SONAR-20721 Improve day picker accessiblity --- .../DatePickerCustomCalendarNavigation.tsx | 24 ++++++++++++++-- .../input/__tests__/DatePicker-test.tsx | 28 ++++++++++++++++--- .../input/__tests__/DateRangePicker-test.tsx | 26 ++++++++--------- .../design-system/src/helpers/testUtils.tsx | 11 +++++--- .../resources/org/sonar/l10n/core.properties | 3 ++ 5 files changed, 69 insertions(+), 23 deletions(-) diff --git a/server/sonar-web/design-system/src/components/input/DatePickerCustomCalendarNavigation.tsx b/server/sonar-web/design-system/src/components/input/DatePickerCustomCalendarNavigation.tsx index 6ce279b7ae3..92ad29fae01 100644 --- a/server/sonar-web/design-system/src/components/input/DatePickerCustomCalendarNavigation.tsx +++ b/server/sonar-web/design-system/src/components/input/DatePickerCustomCalendarNavigation.tsx @@ -48,6 +48,16 @@ export function CustomCalendarNavigation(props: CaptionProps) { const intl = useIntl(); + const formatChevronLabel = (date?: Date) => { + if (date === undefined) { + return intl.formatMessage({ id: 'disabled_' }); + } + return `${intl.formatDate(date, { month: 'long', format: 'M' })} ${intl.formatDate(date, { + year: 'numeric', + format: 'y', + })}`; + }; + const baseDate = startOfMonth(displayMonth); // reference date const months = range(MONTHS_IN_A_YEAR).map((month) => { @@ -74,8 +84,12 @@ export function CustomCalendarNavigation(props: CaptionProps) {