-
Notifications
You must be signed in to change notification settings - Fork 2.9k
DatePicker: order of callbacks for onSelectDate and onAfterMenuDismiss #4092
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 all commits
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,11 @@ | ||
| { | ||
| "changes": [ | ||
| { | ||
| "packageName": "office-ui-fabric-react", | ||
| "comment": "DatePicker calls onDateSelected then AfterMenuDismissed to follow the same pattern as BaseButton", | ||
| "type": "patch" | ||
| } | ||
| ], | ||
| "packageName": "office-ui-fabric-react", | ||
| "email": "dbrough@microsoft.com" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -290,14 +290,21 @@ export class DatePicker extends BaseComponent<IDatePickerProps, IDatePickerState | |
| private _onSelectDate(date: Date) { | ||
| const { formatDate, onSelectDate } = this.props; | ||
|
|
||
| if (this.props.calendarProps && this.props.calendarProps.onSelectDate) { | ||
|
Member
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. Out of curiosity, why do we have onSelectDate and calendarProps.onSelectDate?
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. according to Drew, we are going to be passing calendarProps.onSelectDate so that we know whether the date was selected by the actual calendar drop down or whether it was typed, he needs to set a flag in the consumer. This was always an accepted parameter but before this change we were just overriding and ignoring the calendarProps.onSelectDate, no one used it so no one noticed before. |
||
| this.props.calendarProps.onSelectDate(date); | ||
| } | ||
|
|
||
| this.setState({ | ||
| selectedDate: date, | ||
| isDatePickerShown: false, | ||
| formattedDate: formatDate && date ? formatDate(date) : '', | ||
| }, () => { | ||
| if (onSelectDate) { | ||
| onSelectDate(date); | ||
| } | ||
| }); | ||
|
|
||
| if (onSelectDate) { | ||
| onSelectDate(date); | ||
| } | ||
|
|
||
| this.setState({ | ||
| isDatePickerShown: false, | ||
| }); | ||
| } | ||
|
|
||
|
|
||
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.
did we have any instances where we were using this and it wasn't firing as expected? I can see that we override the original onSelectDate being passed to Calendar up above, just wanted to check if that was causing problems
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.
verified offline that this is expected and correct, and that both the sample page and calendar app are working with this change.