fix(DatePicker/DateRangePicker/Calendar/RangeCalendar)!: make weekStartsOn locale-independent
#2359
+15
−2
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.
resolves #2157
resolves #2264
❗❗This may be a breaking change for those who rely on
weekStartsOnto behave differently across locales.As I've seen more users confused by this implicit behavior, I think it's better to define
weekStartsOnin a fixed and explicit way, where the day of the week is alwaysSun(0), Mon(1), ..., Sat(6). This also aligns with other date libraries, e.g., date-fns, making it more predictable.However, this would break users who rely on the previous behavior by specifying different
weekStartsOnvalues for different locales to make the calendar always start on "Monday" or other days.For example:
Before:
locale="en-GB" :weekStartsOn="0"===locale="en-US" :weekStartsOn="1"==="week starts on Monday"After:
locale="en-GB" :weekStartsOn="1"===locale="en-US" :weekStartsOn="1"==="week starts on Monday"I've also considered adding a new prop (e.g.,
fixedWeekStartsOn: boolean) to only change the behavior when this prop is set, which could avoid breaking changes. However, this would add complexity to the library, and the default behavior would still remain confusing (and we'd have to document it, etc.). WDYT? cc @zernonia