✨ Add weekday class support to datepicker days #6219
+32
−11
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: #6217
Problem
As mentioned in the attached issue, we have a problem with an existing feature of adding a week day class to the day component. Initially we were applying the class based on the weekday short name (E.g.
react-datepicker__day--mon) as documented in this PR. However, when we removed the support of moment js, we started applying the class based on the day of month code (E.g.react-datepicker__day--001) as we useddddinstead ofEEEin the formatDate function ofgetDayOfWeekCode. This was updated long back and now many test cases are relying on the month day class names (E.g.react-datepicker__day--001).In this PR, I reapplied the class based on the weekday short name (E.g.
react-datepicker__day--mon) as documented in this PR, without removing the month day class names. I also added a test case to verify that the class is applied correctly.Note:
This PR is related to my another PR, where I updated the function name from getDayOfWeekCode to getDayOfMonthCode to match it's usage in the codebase.
I did not add any new examples to the docs-site as it's just an addition of a new class name to the day component without any other changes. In case you want to add any new examples, please let me know.
Changes
react-datepicker__day--mon) as documented in this PR, without removing the month day class names.getWeekdayShortInLocaleto get the weekday short name in the default locale (en).Contribution checklist