fix: make calendar respect user's locale for first day of week #3619
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.
Summary
Fix calendar picker to respect user's locale settings for first day of the week by switching from navigator.language to moment.js locale detection.
Types of changes
Changes visible to users:
fix
- non-breaking change which fixes an issue)Description
Changes
getFirstDayOfWeekFromMoment()
helper function usingmoment.locale()
andmoment.localeData().firstDayOfWeek()
Intl.Locale(navigator.language).weekInfo?.firstDay
approach with moment.js locale dataTechnical Details
The previous implementation using
Intl.Locale(navigator.language).weekInfo?.firstDay
was not returning the correct first day of the week value according to user locale. The new implementation useswindow.moment.locale()
andwindow.moment.localeData().firstDayOfWeek()
to determine the first day of the week. This leverages the existing moment.js already used throughout the plugin and provides more reliable locale detection.Motivation and Context
The calendar picker in the Edit Task view was not respecting user's regional preferences for the first day of the week. This was caused by the
navigator.language
API being an incorrect way of determining the user regional settings.How has this been tested?
Screenshots (if appropriate)
N/A - This is a functional fix that affects calendar behavior rather than visual appearance.
Checklist
yarn run lint
.Terms