Date picker: Ensure we use the new props when updating the weeks in the picker#1732
Merged
johannao76 merged 16 commits intomicrosoft:masterfrom May 8, 2017
Merged
Date picker: Ensure we use the new props when updating the weeks in the picker#1732johannao76 merged 16 commits intomicrosoft:masterfrom
johannao76 merged 16 commits intomicrosoft:masterfrom
Conversation
MLoughry
requested changes
May 5, 2017
| this.state = { | ||
| activeDescendantId: getId('DatePickerDay-active'), | ||
| weeks: this._getWeeks(navigatedDate, selectedDate, today) | ||
| weeks: this._getWeeks(props.navigatedDate, props.selectedDate, props.dateRangeType, props.firstDayOfWeek, today) |
Contributor
There was a problem hiding this comment.
Why add the props. reference here, rather than using the destructive assignment above on line 67?
|
|
||
| this.setState({ | ||
| weeks: this._getWeeks(navigatedDate, selectedDate, today) | ||
| weeks: this._getWeeks(nextProps.navigatedDate, nextProps.selectedDate, nextProps.dateRangeType, nextProps.firstDayOfWeek, today) |
|
|
||
| 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.
Why not just pass in the props object here, rather than 5 different arguments (all of which are sourced directly from a props object)?
MLoughry
reviewed
May 5, 2017
| let { navigatedDate, selectedDate, dateRangeType, firstDayOfWeek } = propsToUse; | ||
| let date = new Date(navigatedDate.getFullYear(), navigatedDate.getMonth(), 1); | ||
| let today = todayDate || new Date(); | ||
| let today = propsToUse.today || new Date(); |
Contributor
There was a problem hiding this comment.
Just destruct today from propsToUse as well, and rename the local variable.
MLoughry
approved these changes
May 5, 2017
MLoughry
reviewed
May 8, 2017
| let { navigatedDate, selectedDate, dateRangeType, firstDayOfWeek, today } = propsToUse; | ||
| let date = new Date(navigatedDate.getFullYear(), navigatedDate.getMonth(), 1); | ||
| let today = propsToUse.today || new Date(); | ||
| let todaysDate = today || new Date(); |
Contributor
There was a problem hiding this comment.
You need to update the reference to today on line 281 as well.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Pull request checklist
There was a bug where when new props were provided for dateRangeType and firstDayOfWeek, the week generation code was using the old values so the prop change wasn't getting reflected. Fixed by passing these as parameters to _getWeeks and using the new prop values when these were updated.
Focus areas to test
(optional)