Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 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 @@ -64,11 +64,9 @@ export class CalendarDay extends BaseComponent<ICalendarDayProps, ICalendarDaySt
public constructor(props: ICalendarDayProps) {
super(props);

const { navigatedDate, selectedDate, today } = props;

this.state = {
activeDescendantId: getId('DatePickerDay-active'),
weeks: this._getWeeks(navigatedDate, selectedDate, today)
weeks: this._getWeeks(props)
};

this._onSelectNextMonth = this._onSelectNextMonth.bind(this);
Expand All @@ -79,7 +77,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)
});
}

Expand Down Expand Up @@ -251,10 +249,10 @@ export class CalendarDay extends BaseComponent<ICalendarDayProps, ICalendarDaySt
}
}

private _getWeeks(navigatedDate: Date, selectedDate: Date, todayDate: Date): IDayInfo[][] {
let { firstDayOfWeek, dateRangeType } = this.props;
private _getWeeks(propsToUse: ICalendarDayProps): IDayInfo[][] {
let { navigatedDate, selectedDate, dateRangeType, firstDayOfWeek, today } = propsToUse;
let date = new Date(navigatedDate.getFullYear(), navigatedDate.getMonth(), 1);
let today = todayDate || new Date();
let todaysDate = today || new Date();

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.

You need to update the reference to today on line 281 as well.

let weeks = [];
let week;

Expand Down