* Make sure we set the onMonthPreviewed prop as this is required for wp.components.DatePicker

* Add changelogs
This commit is contained in:
louwie17 2021-12-03 09:29:27 -04:00 committed by GitHub
parent 0cb4382c05
commit 7eeb77acc3
3 changed files with 9 additions and 1 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: Fix
Fix usage of Wordpress DatePicker component. #7982

View File

@ -1,5 +1,7 @@
# Unreleased
- Fix usage of Wordpress DatePicker component in `DatePicker`. #7982
# 8.1.1
- Fixed warnings when using AdvancedFilters component. #7704

View File

@ -6,7 +6,7 @@ import 'core-js/features/array/from';
import { __, sprintf } from '@wordpress/i18n';
import { createElement, Component } from '@wordpress/element';
import { Dropdown, DatePicker as WpDatePicker } from '@wordpress/components';
import { partial } from 'lodash';
import { partial, noop } from 'lodash';
import moment from 'moment';
import PropTypes from 'prop-types';
import { dateValidationMessages, toMoment } from '@woocommerce/date';
@ -127,6 +127,8 @@ class DatePicker extends Component {
this.onDateChange,
onToggle
) }
// onMonthPreviewed is required to prevent a React error from happening.
onMonthPreviewed={ noop }
isInvalidDate={ isInvalidDate }
/>
</div>