Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
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
Expand Up @@ -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) {
Copy link
Contributor

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

Copy link
Contributor

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.

Copy link
Member

Choose a reason for hiding this comment

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

Out of curiosity, why do we have onSelectDate and calendarProps.onSelectDate?

Copy link
Contributor

Choose a reason for hiding this comment

The 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,
});
}

Expand Down