Skip to content
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

DatePicker: order of callbacks for onSelectDate and onAfterMenuDismiss #4092

Merged

Conversation

drew-brough
Copy link
Member

Pull request checklist

  • Addresses an existing issue: Fixes #0000
  • Include a change request file using $ npm run change

Description of changes

We recently added an "onAfterMenuDismiss" to datePicker, however the order in which it was getting called relative to the onSelectDate was opposite of the pattern established in BaseButton when a menu is used. DatePicker was using the callback from setting the state to hide the menu to do the selection callback.
With this change, we'll set the component state with the new date, call the onSelectDate callbacks, then set the state to dismiss the Calendar menu.
The component was also over-writing the onSelectDate option that was available via the calendarProps prop, so we'll call that immediately should the caller provide it, then deal with local state and callbacks.

@@ -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.

@@ -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
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.

@lorejoh12 lorejoh12 merged commit 9b2f25a into microsoft:master Feb 26, 2018
Markionium added a commit to Markionium/office-ui-fabric-react that referenced this pull request Feb 27, 2018
* master: (28 commits)
  Scrollable pane sort stickies (microsoft#4111)
  Allow ScrollablePane to accept native properties. (microsoft#4095)
  Sticky (microsoft#4091)
  Applying package updates.
  [ColorRectangle, Sticky] Fixed null root refs (microsoft#4099)
  DatePicker: order of callbacks for onSelectDate and onAfterMenuDismiss (microsoft#4092)
  Applying package updates.
  Alhenry fix split button props (microsoft#4090)
  Fixing ComboBox styling by reverting button classname move (microsoft#4088)
  Update CODEOWNERS
  Undoing terrible change.
  [DetailsList] Fixed focus test (microsoft#4087)
  Added icons package screener test (microsoft#4082)
  ContextualMenu: Fix ContextualMenuUtility imports (microsoft#4085)
  [ContextualMenu] Made disabled buttons focusable (microsoft#4074)
  Convert Check to mergeStyles (microsoft#3880)
  [DetailsList] Add public focusIndex function (microsoft#3852)
  ComboBox button should have data-is-focusable="false" (microsoft#4070)
  Applying package updates.
  Focus Zone: Allow Tab to Skip Selection (microsoft#4061)
  ...
chrismohr pushed a commit to chrismohr/office-ui-fabric-react that referenced this pull request Apr 17, 2018
microsoft#4092)

* change the order of callbacks and dismissal to more closely match the order that command button handles its menu

* change file
@microsoft microsoft locked as resolved and limited conversation to collaborators Aug 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants