Skip to content

Commit

Permalink
[RNMobile] Native mobile release v1.7.0 (#16156)
Browse files Browse the repository at this point in the history
* [Mobile] Disable Video block on Android for v1.7.0 release (#16149)

* Disable Video block on Android for v1.7.0 release

* Add import statement to check platform

* [RNMobile] Narrow down blur on unmount to replaceable only (#16151)

* Remove focus from RichText when unmounting

In #15999 this behavior was changed to prevent the keyboard from disappearing
when you press Enter to create a new paragraph.

This worked in that case, but had the side effect of TextInputState still
thinking a dead view had focus, and causing a crash in some scenarios.

* Only blur a RichText in replaceable block

That RichText won't have the chance to blur earlier so, we need to do it
on unmount. But, non replaceable blocks wont need to blur their RichText
on unmount because that will happen normally in componentDidUpdate().

* Rename to an unstable, very goal-named name

* Compute shouldBlurOnUnmount inside RichText

* Fix no-duplicate-imports lint issue

* Fix comma-dangle lint error

* Remove trailing space from comment
  • Loading branch information
hypest authored Jun 14, 2019
1 parent dcd0041 commit 714d561
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
18 changes: 15 additions & 3 deletions packages/block-editor/src/components/rich-text/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ import {
} from '@wordpress/rich-text';
import { decodeEntities } from '@wordpress/html-entities';
import { BACKSPACE } from '@wordpress/keycodes';
import { pasteHandler, children } from '@wordpress/blocks';
import {
children,
isUnmodifiedDefaultBlock,
pasteHandler,
} from '@wordpress/blocks';
import { isURL } from '@wordpress/url';

/**
Expand Down Expand Up @@ -706,8 +710,8 @@ export class RichText extends Component {
}

componentWillUnmount() {
if ( this._editor.isFocused() ) {
// this._editor.blur();
if ( this._editor.isFocused() && this.props.shouldBlurOnUnmount ) {
this._editor.blur();
}
}

Expand Down Expand Up @@ -880,6 +884,7 @@ const RichTextContainer = compose( [
const {
getSelectionStart,
getSelectionEnd,
__unstableGetBlockWithoutInnerBlocks,
} = select( 'core/block-editor' );

const selectionStart = getSelectionStart();
Expand All @@ -892,12 +897,19 @@ const RichTextContainer = compose( [
);
}

// If the block of this RichText is unmodified then it's a candidate for replacing when adding a new block.
// In order to fix https://github.com/wordpress-mobile/gutenberg-mobile/issues/1126, let's blur on unmount in that case.
// This apparently assumes functionality the BlockHlder actually
const block = clientId && __unstableGetBlockWithoutInnerBlocks( clientId );
const shouldBlurOnUnmount = block && isSelected && isUnmodifiedDefaultBlock( block );

return {
formatTypes: getFormatTypes(),
selectionStart: isSelected ? selectionStart.offset : undefined,
selectionEnd: isSelected ? selectionEnd.offset : undefined,
isSelected,
blockIsSelected,
shouldBlurOnUnmount,
};
} ),
withDispatch( ( dispatch, {
Expand Down
10 changes: 10 additions & 0 deletions packages/edit-post/src/index.native.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* External dependencies
*/
import { Platform } from 'react-native';

/**
* WordPress dependencies
*/
Expand All @@ -22,6 +27,11 @@ export function initializeEditor() {
// eslint-disable-next-line no-undef
if ( typeof __DEV__ === 'undefined' || ! __DEV__ ) {
unregisterBlockType( 'core/code' );

// Disable Video block except for iOS for now.
if ( Platform.OS !== 'ios' ) {
unregisterBlockType( 'core/video' );
}
}
}

0 comments on commit 714d561

Please sign in to comment.