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

[RNMobile] Fix missing block title of core/latest-posts block #34116

Merged
merged 1 commit into from
Aug 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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