Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions common/changes/minimonthfixes_2017-05-05-17-02.json
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
Expand Up @@ -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)

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

};

this._onSelectNextMonth = this._onSelectNextMonth.bind(this);
Expand All @@ -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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

});
}

Expand Down Expand Up @@ -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[][] {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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)?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The 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 = [];
Expand Down