Skip to content

Commit

Permalink
fix: aria labels for the grid
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed Feb 15, 2025
1 parent 883f913 commit 8485ce9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/core/src/useCalendar/useCalendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ export function useCalendar(_props: Reactivify<CalendarProps, 'onDaySelected'> =

const nextPanelButtonProps = useControlButtonProps(() => ({
id: `${calendarId}-next`,
'aria-label': 'Next',
onClick: () => {
if (currentPanel.value.type === 'day') {
context.setFocusedDate(context.getFocusedDate().add({ months: 1 }));
Expand All @@ -212,6 +213,7 @@ export function useCalendar(_props: Reactivify<CalendarProps, 'onDaySelected'> =

const previousPanelButtonProps = useControlButtonProps(() => ({
id: `${calendarId}-previous`,
'aria-label': 'Previous',
onClick: () => {
if (currentPanel.value.type === 'day') {
context.setFocusedDate(context.getFocusedDate().subtract({ months: 1 }));
Expand All @@ -227,7 +229,7 @@ export function useCalendar(_props: Reactivify<CalendarProps, 'onDaySelected'> =
},
}));

const { labelProps: monthYearLabelBaseProps } = useLabel({
const { labelProps: monthYearLabelBaseProps, labelledByProps } = useLabel({
targetRef: gridEl,
for: gridId,
label: panelLabel,
Expand Down Expand Up @@ -267,8 +269,9 @@ export function useCalendar(_props: Reactivify<CalendarProps, 'onDaySelected'> =

return withRefCapture(
{
id: `${calendarId}-g`,
id: gridId,
role: 'grid',
...labelledByProps.value,
style: {
display: 'grid',
gridTemplateColumns: `repeat(${columns}, 1fr)`,
Expand Down

0 comments on commit 8485ce9

Please sign in to comment.