Skip to content

Fix #6223 - ♿ Accessibility improvements: Month and Year dropdowns#6232

Open
balajis-qb wants to merge 2 commits intoHacker0x01:mainfrom
qburst:issue-6223/fix/month-dropdown-accessibility
Open

Fix #6223 - ♿ Accessibility improvements: Month and Year dropdowns#6232
balajis-qb wants to merge 2 commits intoHacker0x01:mainfrom
qburst:issue-6223/fix/month-dropdown-accessibility

Conversation

@balajis-qb
Copy link
Copy Markdown
Contributor

@balajis-qb balajis-qb commented Jan 28, 2026

Description

Linked issue: #6223

Problem
As mentioned in the attached ticket, the month select dropdown (showMonthDropdown) and the year select drop down (showYearDropdown) lacks ARIA attributes.

Changes

  • Added the corresponding aria attributes to the select and the button element to support the dropdown mode (dropdownMode) of scroll and select
  • Added test cases to validate the change

Contribution checklist

  • I have followed the contributing guidelines.
  • I have added sufficient test coverage for my changes.
  • I have formatted my code with Prettier and checked for linting issues with ESLint for code readability.

@balajis-qb balajis-qb force-pushed the issue-6223/fix/month-dropdown-accessibility branch from 5cbdd4d to 7f61d82 Compare January 28, 2026 16:58
@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.29%. Comparing base (548a1f3) to head (7f61d82).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6232   +/-   ##
=======================================
  Coverage   99.29%   99.29%           
=======================================
  Files          30       30           
  Lines        3822     3824    +2     
  Branches     1648     1667   +19     
=======================================
+ Hits         3795     3797    +2     
  Misses         26       26           
  Partials        1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

@halvorsanden halvorsanden left a comment

Choose a reason for hiding this comment

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

I’m glad to see this being worked on. I think this would benefit from taking a step back and simplifying and considering the elements, roles and context too, so it doesn’t end up with more aria than necessary.

My comments are mainly from experience with making comboboxes, which aren’t that different from this. I find https://www.w3.org/WAI/ARIA/apg/patterns/ very useful, and I also recommend inspecting the solution in the accessibility tree and, if you’re not doing it already, test it with your OS screen reader.

I commented on the month section, but the same goes for the year.

Comment thread src/month_dropdown.tsx
key={m}
value={i}
aria-label={`Select Month ${m}`}
aria-selected={i === this.props.month ? "true" : "false"}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

aria-label is not necessary here, the value is already inside this element and the context this appears in already communicates that this is an option that can be selected.
The same with aria-selected I believe, the option element is inside a select element, both have built-in roles and meaning stating what is selected.
Adding aria to elements like these that already have the semantics and meaning built-in can make things less accessible because it is announced differently than the user might expect when encountering the native HTML elements.

Comment thread src/month_dropdown.tsx
value={this.props.month}
className="react-datepicker__month-select"
onChange={(e) => this.onChange(parseInt(e.target.value))}
aria-label="Select Month"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is what the referred issue points to, and also what I’m after, but this should be a prop so it can use i18n. If a default is needed, I would recommend only "Month" since "select" is already given by the element type. The entire date dialog is also announced as "choose date", so there is no need to repeat "select/choose" too many places.

Comment thread src/month_dropdown.tsx
style={{ visibility: visible ? "visible" : "hidden" }}
className="react-datepicker__month-read-view"
onClick={this.toggleDropdown}
aria-label="Select Month"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This would make the element always announce "Select month" even when a month has been selected.

Comment thread src/month_dropdown.tsx
onClick={this.toggleDropdown}
aria-label="Select Month"
aria-expanded={this.state.dropdownVisible}
aria-haspopup="listbox"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This also needs a reference to what element it opens and what element has keyboard focus when the element is open. An aria-controls that takes the id of the related element and an aria-activedescendant with the focused element.

}
}}
role="button"
aria-label={`Select Month ${month}`}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The role of this element should most likely be changed to "option" rather than adding an aria-label, if the parent element is a listbox. I would also change the parent to a ul element and this from a div to a li.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants