-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Date picker: Ensure we use the new props when updating the weeks in the picker #1732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 13 commits
6bdbba7
acd2361
676a995
ab1653b
ea804d3
f18cb9d
fdaac8f
3df45d6
a0a0b4c
21c030c
ca03506
6063694
bb03faf
1bedcc7
b50ba3b
20cfe17
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "changes": [ | ||
| { | ||
| "packageName": "office-ui-fabric-react", | ||
| "comment": "Day picker: Ensure we use values from nextProps when props are updated when generating weeks", | ||
| "type": "patch" | ||
| } | ||
| ], | ||
| "email": "johannao@microsoft.com" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,7 +68,7 @@ export class CalendarDay extends BaseComponent<ICalendarDayProps, ICalendarDaySt | |
|
|
||
| this.state = { | ||
| activeDescendantId: getId('DatePickerDay-active'), | ||
| weeks: this._getWeeks(navigatedDate, selectedDate, today) | ||
| weeks: this._getWeeks(props.navigatedDate, props.selectedDate, props.dateRangeType, props.firstDayOfWeek, today) | ||
| }; | ||
|
|
||
| this._onSelectNextMonth = this._onSelectNextMonth.bind(this); | ||
|
|
@@ -79,7 +79,7 @@ export class CalendarDay extends BaseComponent<ICalendarDayProps, ICalendarDaySt | |
| const { navigatedDate, selectedDate, today } = nextProps; | ||
|
|
||
| this.setState({ | ||
| weeks: this._getWeeks(navigatedDate, selectedDate, today) | ||
| weeks: this._getWeeks(nextProps.navigatedDate, nextProps.selectedDate, nextProps.dateRangeType, nextProps.firstDayOfWeek, today) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed |
||
| }); | ||
| } | ||
|
|
||
|
|
@@ -251,8 +251,7 @@ export class CalendarDay extends BaseComponent<ICalendarDayProps, ICalendarDaySt | |
| } | ||
| } | ||
|
|
||
| private _getWeeks(navigatedDate: Date, selectedDate: Date, todayDate: Date): IDayInfo[][] { | ||
| let { firstDayOfWeek, dateRangeType } = this.props; | ||
| private _getWeeks(navigatedDate: Date, selectedDate: Date, dateRangeType: DateRangeType, firstDayOfWeek: DayOfWeek, todayDate: Date): IDayInfo[][] { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not just pass in the props object here, rather than 5 different arguments (all of which are sourced directly from a props object)?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Passing props |
||
| let date = new Date(navigatedDate.getFullYear(), navigatedDate.getMonth(), 1); | ||
| let today = todayDate || new Date(); | ||
| let weeks = []; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why add the
props.reference here, rather than using the destructive assignment above on line 67?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed