Skip to content

Commit

Permalink
DatePicker: Fix crash when navigating between months (#31751)
Browse files Browse the repository at this point in the history
  • Loading branch information
mirka authored Jun 16, 2021
1 parent 8d986c9 commit 749088d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/components/src/date-time/date.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class DatePicker extends Component {
}

onMonthPreviewedHandler( newMonthDate ) {
this.props?.onMonthPreviewed( newMonthDate.toISOString() );
this.props.onMonthPreviewed?.( newMonthDate.toISOString() );
this.keepFocusInside();
}

Expand Down
17 changes: 17 additions & 0 deletions packages/components/src/date-time/stories/date.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Internal dependencies
*/
import DatePicker from '../date';

/**
* WordPress dependencies
*/
import { useState } from '@wordpress/element';

export default { title: 'Components/DatePicker', component: DatePicker };

export const _default = () => {
const [ date, setDate ] = useState();

return <DatePicker currentDate={ date } onChange={ setDate } />;
};

0 comments on commit 749088d

Please sign in to comment.