diff --git a/packages/block-library/src/heading/edit.native.js b/packages/block-library/src/heading/edit.native.js index ac751101fb144..2c16443fccbda 100644 --- a/packages/block-library/src/heading/edit.native.js +++ b/packages/block-library/src/heading/edit.native.js @@ -6,7 +6,7 @@ import HeadingToolbar from './heading-toolbar'; /** * External dependencies */ -import { View } from 'react-native'; +import { View, Platform } from 'react-native'; /** * WordPress dependencies @@ -23,6 +23,7 @@ class HeadingEdit extends Component { super( props ); this.splitBlock = this.splitBlock.bind( this ); + this.isAndroid = Platform.OS === 'android'; } /** @@ -101,6 +102,9 @@ class HeadingEdit extends Component { onMerge={ mergeBlocks } onSplit={ this.splitBlock } placeholder={ placeholder || __( 'Write heading…' ) } + // Fix for heading issue on Android https://github.com/wordpress-mobile/gutenberg-mobile/issues/627 + // Intentionally introduces missing pleceholder issue on Android https://github.com/wordpress-mobile/gutenberg-mobile/issues/707 + sendEmptyTag={ this.isAndroid } /> ); diff --git a/packages/editor/src/components/rich-text/index.native.js b/packages/editor/src/components/rich-text/index.native.js index b291d211e4652..5cf1bb3fd2eb0 100644 --- a/packages/editor/src/components/rich-text/index.native.js +++ b/packages/editor/src/components/rich-text/index.native.js @@ -496,6 +496,7 @@ export class RichText extends Component { style, formattingControls, isSelected, + sendEmptyTag, } = this.props; const record = this.getRecord(); @@ -503,8 +504,20 @@ export class RichText extends Component { const value = this.valueToFormat( record ); let html = `<${ tagName }>${ value }`; // We need to check if the value is undefined or empty, and then assign it properly otherwise the placeholder is not visible + if ( value === undefined || value === '' ) { - html = ''; + // PR for placeholder fix https://github.com/WordPress/gutenberg/pull/13699/ + // has introduced heading issue on Android https://github.com/wordpress-mobile/gutenberg-mobile/issues/627 + // ( If a new heading block is created on Android device + // it will be without default formatting (

currently ) ) . + // Fix for heading issue is to skip reset of html variable if tag is heading and platform is Android. + // This fix will intentionally introduce original issue with placeholder (on Android) + // which has lower priority then heading issue . + // New issue is raised : https://github.com/wordpress-mobile/gutenberg-mobile/issues/707 + if ( ! sendEmptyTag ) { + html = ''; + } + this.lastEventCount = undefined; // force a refresh on the native side } let minHeight = 0;