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 title for some unsupported blocks #31743

Merged
merged 4 commits into from
May 18, 2021
Merged
Show file tree
Hide file tree
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
17 changes: 15 additions & 2 deletions packages/block-library/src/missing/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { compose, withPreferredColorScheme } from '@wordpress/compose';
import { coreBlocks } from '@wordpress/block-library';
import { normalizeIconObject } from '@wordpress/blocks';
import { Component } from '@wordpress/element';
import { __, sprintf } from '@wordpress/i18n';
import { __, _x, sprintf } from '@wordpress/i18n';
import { help, plugins } from '@wordpress/icons';
import { withSelect, withDispatch } from '@wordpress/data';
import { applyFilters } from '@wordpress/hooks';
Expand All @@ -34,6 +34,7 @@ import styles from './style.scss';

// Blocks that can't be edited through the Unsupported block editor identified by their name.
const UBE_INCOMPATIBLE_BLOCKS = [ 'core/block' ];
const I18N_BLOCK_SCHEMA_TITLE = 'block title';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


export class UnsupportedBlockEdit extends Component {
constructor( props ) {
Expand Down Expand Up @@ -63,6 +64,18 @@ export class UnsupportedBlockEdit extends Component {
}
}

getTitle() {
const { originalName } = this.props.attributes;
const blockType = coreBlocks[ originalName ];
const title = blockType?.metadata.title;
const textdomain = blockType?.metadata.textdomain;

return title && textdomain
? // eslint-disable-next-line @wordpress/i18n-no-variables, @wordpress/i18n-text-domain
_x( title, I18N_BLOCK_SCHEMA_TITLE, textdomain )
: originalName;
}

renderHelpIcon() {
const infoIconStyle = this.props.getStylesFromColorScheme(
styles.infoIcon,
Expand Down Expand Up @@ -225,7 +238,7 @@ export class UnsupportedBlockEdit extends Component {
const { getStylesFromColorScheme, preferredColorScheme } = this.props;
const blockType = coreBlocks[ originalName ];

const title = blockType ? blockType.settings.title : originalName;
const title = this.getTitle();
const titleStyle = getStylesFromColorScheme(
styles.unsupportedBlockMessage,
styles.unsupportedBlockMessageDark
Expand Down
1 change: 1 addition & 0 deletions packages/react-native-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ For each user feature we should also add a importance categorization label to i
- [*] Fixes color picker rendering bug when scrolling [#30994]
- [*] Add enableCaching param to fetch request on Android [#31186]
- [*] Disabled featured image banner on iOS. [#31681]
- [*] Fix missing title for some unsupported blocks [#31743]

## 1.52.1

Expand Down