showMonthYearPicker and showYearPicker have keyboard-select css class on not selected item
Describe the bug
Month and year pickers have react-datepicker__month-text--keyboard-selected CSS class.
Since keyboard navigation is not supported (or not working) for these pickers, picked month, year should not have this CSS class.
The problem is it messes with the stylings of the selected month (year).
To Reproduce react and react-dom: 16.14.0 react-datepicker: 4.6.0
Use this example:
() => {
const [startDate, setStartDate] = useState(new Date());
return (
<DatePicker
selected={startDate}
onChange={(date) => setStartDate(date)}
dateFormat="MM/yyyy"
showMonthYearPicker // or showYearPicker
/>
);
};
- Select February in 2022
- selected div has
react-datepicker__month--selected react-datepicker__month-text--keyboard-selectedclasses which are somewhat correct even though keyboard navigation does not work with year or month pickers
- selected div has
- Go to the previous year
- February in 2021 also is highlighted as selected
- div has
react-datepicker__month-text--keyboard-selectedwhich messes with styles.
- div has
Same thing happens in year picker but with their respective CSS classes.
Expected behavior
Since year and month pickers do not support keyboard navigation, they should not use keyboard-navigation styles.
And if they should support keyboard navigation in the future let the disabledKeyboardNavigation property dictate whether keyboard navigation CSS classes are used for styling.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Update
I am experiencing the same issue even in v6.9.0. In which version was it resolved?