Skip to content

Commit

Permalink
fix(DatePicker): Add aria-label to calendar header columns. (#1528)
Browse files Browse the repository at this point in the history
Co-authored-by: Nikita Orliak <[email protected]>
  • Loading branch information
nikitaorliak-cengage and Nikita Orliak authored Nov 6, 2024
1 parent e02cd4e commit 8004c9f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/a11y-datepicker-calendar-header-columns.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'react-magma-dom': patch
---

fix(DatePicker): Add `aria-label` to calendar header columns.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,12 @@ export const CalendarMonth: React.FunctionComponent<CalendarMonthProps> = (
const startOfWeek = days.indexOf(i18n.datePicker.startOfWeek);
const sortedDays = days.slice(startOfWeek).concat(days.slice(0, startOfWeek));
const tableDaysHeaders = sortedDays.map((day, index) => (
<Th key={index} theme={theme} isInverse={context.isInverse}>
<Th
key={index}
theme={theme}
isInverse={context.isInverse}
aria-label={i18n.days.long[day]}
>
{i18n.days.min[day]}
</Th>
));
Expand Down
18 changes: 15 additions & 3 deletions website/react-magma-docs/src/pages/api/date-pickers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ import React from 'react';
import { DatePicker, getDateFromString, inDateRange } from 'react-magma-dom';

export function Example() {
const [chosenDate, setChosenDate] = React.useState<Date | undefined>(
const [chosenDate, setChosenDate] = React.useState<Date | undefined>(
undefined
);
const minDate = '01/09/2024';
Expand All @@ -76,9 +76,12 @@ export function Example() {
const convertedMinDate = getDateFromString(minDate);
const convertedMaxDate = getDateFromString(maxDate);

if (chosenDate && !inDateRange(chosenDate, convertedMinDate, convertedMaxDate)) {
if (
chosenDate &&
!inDateRange(chosenDate, convertedMinDate, convertedMaxDate)
) {
return `Please enter a date within the range ${minDate} - ${maxDate}`;
}
}

return;
}
Expand Down Expand Up @@ -416,6 +419,15 @@ export function Example() {
friday: 'V',
saturday: 'S',
},
long: {
sunday: 'Domingo',
monday: 'Lunes',
tuesday: 'Martes',
wednesday: 'Miércoles',
thursday: 'Jueves',
friday: 'Viernes',
saturday: 'Sábado',
},
},
datePicker: {
...defaultI18n.datePicker,
Expand Down

2 comments on commit 8004c9f

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.