fix: showMonthYearDropdown not keyboard/tab accessible#86
Open
balajis-qb wants to merge 2 commits into
Open
Conversation
Fixes Hacker0x01#6311 MonthYearDropdown.renderReadView rendered its toggle as a plain <div onClick>, unlike MonthDropdown/YearDropdown which use <button type="button">, so it was skipped by Tab and did not respond to Enter/Space. Switch it to a button; the shared *-read-view CSS already covers all three variants.
MonthYearDropdownOptions rendered each option as a plain <div> with no role, tabIndex, onKeyDown, or focus management, unlike MonthDropdownOptions/YearDropdownOptions. Once the read-view toggle became reachable via Tab, the opened list still couldn't be navigated by keyboard. Add role="button", tabIndex, Enter/Escape/ ArrowUp/ArrowDown handling, and auto-focus of the selected option, matching the existing month/year dropdown pattern.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Linked issue: Hacker0x01#6311
Problem
When
showMonthYearDropdownis enabled:MonthYearDropdown.renderReadView) rendered as a plain<div onClick>instead of a<button type="button">likeMonthDropdown/YearDropdown, so it was skipped byTaband didn't respond toEnter/Space.MonthYearDropdownOptions) rendered each option as a plain<div>with norole,tabIndex,onKeyDown, or focus management, unlikeMonthDropdownOptions/YearDropdownOptions, so the list itself couldn't be navigated by keyboard even after the toggle became reachable.Changes
src/month_year_dropdown.tsx: changed the read-view toggle from<div>to<button type="button">.src/month_year_dropdown_options.tsx: addedrole="button",tabIndex, andonKeyDownhandling (Enterselects,Escapecancels,ArrowUp/ArrowDownmoves focus between options without wrapping) plus auto-focus of the selected option when the list opens — matching the existingMonthDropdownOptions/YearDropdownOptionspattern.src/test/month_year_dropdown_test.test.tsx: added regression tests covering the button read view and the new keyboard navigation/focus behavior.Contribution checklist