Skip to content

Commit

Permalink
Fix: Calendar block: Always show current month for non post types on …
Browse files Browse the repository at this point in the history
…the editor
  • Loading branch information
jorgefilipecosta committed Feb 14, 2019
1 parent c6255ed commit 5ae3e6d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion packages/block-library/src/calendar/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,16 @@ class CalendarEdit extends Component {
}

export default withSelect( ( select ) => {
const {
getEditedPostAttribute,
} = select( 'core/editor' );
const postType = getEditedPostAttribute( 'type' );
// Dates are used to overwrite year and month used on the calendar.
// This overwrite should only happen for 'post' post types.
// For other post types the calendar always displays the current month.
return {
date: select( 'core/editor' ).getEditedPostAttribute( 'date' ),
date: postType === 'post' ?
getEditedPostAttribute( 'date' ) :
undefined,
};
} )( CalendarEdit );
2 changes: 1 addition & 1 deletion packages/block-library/src/calendar/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @return string Returns the block content.
*/
function render_block_core_calendar( $attributes ) {
global $monthnum, $year, $post;
global $monthnum, $year;
$previous_monthnum = $monthnum;
$previous_year = $year;

Expand Down

0 comments on commit 5ae3e6d

Please sign in to comment.