Skip to content

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

Closed
balajis-qb wants to merge 2 commits into
Hacker0x01:mainfrom
qburst:issue-6223/fix/month-dropdown-accessibility
Closed

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

Conversation

@balajis-qb

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

Copy link
Copy Markdown
Contributor

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

codecov Bot commented Jan 28, 2026

Copy link
Copy Markdown

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.

@halvorsanden halvorsanden left a comment

Copy link
Copy Markdown

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed. Removed redundant aria-* from native / to rely on built-in semantics and avoid conflicting announcements. Addressed in the new PR.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Using a default aria-label="Month" for now to keep API minimal and consistent with existing patterns.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated to a neutral label (“Month”) to avoid misleading announcements once a value is 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not adding these since the custom dropdown is not a true combobox pattern. It follows a simpler listbox model, so I feel aria-controls/aria-activedescendant would be unnecessary here.

}
}}
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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated custom dropdown to use ul/li with role="option" for selectable items. Navigation controls remain buttons as they represent actions, not options.

@armhaj

armhaj commented Jun 8, 2026

Copy link
Copy Markdown

Hi, are there any plans to move this PR forward? If it's no longer being worked on, could you please close it so we can create a new PR and implement the necessary fixes?

@balajis-qb

Copy link
Copy Markdown
Contributor Author

Thank you @halvorsanden for your suggestions.

@armhaj, I'll look into the suggested changes and work on that.

@balajis-qb

Copy link
Copy Markdown
Contributor Author

Closing this PR as I ran into issues with the existing branch. I’ve created a new PR with the suggested changes and improvements here

Please feel free to continue the review on the new PR — thanks!

@halvorsanden @armhaj

@balajis-qb balajis-qb closed this Jun 10, 2026
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.

3 participants