Skip to content

Commit

Permalink
[RNMobile] Fix missing block title of core/latest-posts block (#34116)
Browse files Browse the repository at this point in the history
  • Loading branch information
fluiddot authored Aug 17, 2021
1 parent baa1fcb commit 830f485
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions packages/block-library/src/latest-posts/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import { isEmpty } from 'lodash';
*/
import { Component } from '@wordpress/element';
import { compose, withPreferredColorScheme } from '@wordpress/compose';
import { withDispatch } from '@wordpress/data';
import { coreBlocks } from '@wordpress/block-library';
import { withDispatch, withSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
import { postList as icon } from '@wordpress/icons';
import { InspectorControls } from '@wordpress/block-editor';
Expand All @@ -22,6 +21,7 @@ import {
RangeControl,
QueryControls,
} from '@wordpress/components';
import { store as blocksStore } from '@wordpress/blocks';

/**
* Internal dependencies
Expand Down Expand Up @@ -189,14 +189,12 @@ class LatestPostsEdit extends Component {

render() {
const {
blockTitle,
getStylesFromColorScheme,
name,
openGeneralSidebar,
isSelected,
} = this.props;

const blockType = coreBlocks[ name ];

const blockStyle = getStylesFromColorScheme(
styles.latestPostBlock,
styles.latestPostBlockDark
Expand All @@ -221,9 +219,7 @@ class LatestPostsEdit extends Component {
<View style={ blockStyle }>
{ isSelected && this.getInspectorControls() }
<Icon icon={ icon } { ...iconStyle } />
<Text style={ titleStyle }>
{ blockType.settings.title }
</Text>
<Text style={ titleStyle }>{ blockTitle }</Text>
<Text style={ styles.latestPostBlockSubtitle }>
{ __( 'CUSTOMIZE' ) }
</Text>
Expand All @@ -234,6 +230,12 @@ class LatestPostsEdit extends Component {
}

export default compose( [
withSelect( ( select, { name } ) => {
const blockType = select( blocksStore ).getBlockType( name );
return {
blockTitle: blockType?.title || name,
};
} ),
withDispatch( ( dispatch ) => {
const { openGeneralSidebar } = dispatch( 'core/edit-post' );

Expand Down

0 comments on commit 830f485

Please sign in to comment.