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

[Mobile] - Fix splitting/merging of Paragraph and Heading #29502

Merged
merged 4 commits into from
Mar 4, 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: 13 additions & 5 deletions packages/rich-text/src/component/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* WordPress dependencies
*/
import RCTAztecView from '@wordpress/react-native-aztec';
import { View, Platform } from 'react-native';
import { View, Platform, InteractionManager } from 'react-native';
import {
showUserSuggestions,
showXpostSuggestions,
Expand All @@ -18,7 +18,10 @@ import memize from 'memize';
/**
* WordPress dependencies
*/
import { BlockFormatControls } from '@wordpress/block-editor';
import {
BlockFormatControls,
store as blockEditorStore,
} from '@wordpress/block-editor';
import { Component } from '@wordpress/element';
import { compose, withPreferredColorScheme } from '@wordpress/compose';
import { withSelect } from '@wordpress/data';
Expand Down Expand Up @@ -556,6 +559,7 @@ export class RichText extends Component {

// Check if value is up to date with latest state of native AztecView
if (
this.isIOS &&
event.nativeEvent.text &&
event.nativeEvent.text !== this.props.value
) {
Expand Down Expand Up @@ -615,7 +619,9 @@ export class RichText extends Component {

// update text before updating selection
// Make sure there are changes made to the content before upgrading it upward
this.onTextUpdate( event );
if ( this.isIOS ) {
this.onTextUpdate( event );
}

// Aztec can send us selection change events after it has lost focus.
// For instance the autocorrect feature will complete a partially written
Expand Down Expand Up @@ -763,7 +769,9 @@ export class RichText extends Component {
this.props.selectionEnd || 0
);
} else if ( ! isSelected && prevIsSelected ) {
this._editor.blur();
InteractionManager.runAfterInteractions( () => {
this._editor?.blur();
} );
}
}

Expand Down Expand Up @@ -998,7 +1006,7 @@ const withFormatTypes = ( WrappedComponent ) => ( props ) => {
export default compose( [
withSelect( ( select, { clientId } ) => {
const { getBlockParents, getBlock, getSettings } = select(
'core/block-editor'
blockEditorStore
);
const parents = getBlockParents( clientId, true );
const parentBlock = parents ? getBlock( parents[ 0 ] ) : undefined;
Expand Down