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] Refactor BlockToolbar follow-up PR #16906

Merged
merged 4 commits into from Aug 5, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { ScrollView, Keyboard, Platform, View } from 'react-native';
import { ScrollView, View } from 'react-native';

/**
* WordPress dependencies
Expand Down Expand Up @@ -31,14 +31,6 @@ function HeaderToolbar( {
showKeyboardHideButton,
clearSelectedBlock,
} ) {
const hideKeyboard = () => {
clearSelectedBlock();
if ( Platform.OS === 'android' ) {
// Avoiding extra blur calls on iOS but still needed for android.
Keyboard.dismiss();
}
};

return (
<View style={ styles.container }>
<ScrollView
Expand Down Expand Up @@ -75,7 +67,7 @@ function HeaderToolbar( {
<ToolbarButton
title={ __( 'Hide keyboard' ) }
icon="keyboard-hide"
onClick={ hideKeyboard }
onClick={ clearSelectedBlock }
extraProps={ { hint: __( 'Tap to hide the keyboard' ) } }
/>
</Toolbar>
Expand Down
4 changes: 4 additions & 0 deletions packages/editor/src/components/provider/index.native.js
Expand Up @@ -118,6 +118,8 @@ class NativeEditorProvider extends Component {
const { mode, switchMode } = this.props;
// refresh html content first
this.serializeToNativeAction();
// make sure to blur the selected block and dismiss the keyboard
this.props.clearSelectedBlock();
switchMode( mode === 'visual' ? 'text' : 'visual' );
}

Expand Down Expand Up @@ -158,6 +160,7 @@ export default compose( [
} ),
withDispatch( ( dispatch ) => {
const {
clearSelectedBlock,
Copy link
Contributor

@mchowning mchowning Aug 5, 2019

Choose a reason for hiding this comment

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

It looks like clearSelectedBlock from core/editor just calls through to core/block-editor with a deprecation warning that shows up as a Yellow Box warning. Sounds like we should just get this directly from core/block-editor instead of via core/editor.

Screen Shot 2019-08-05 at 12 55 51 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, updated 👍

Copy link
Contributor

@mchowning mchowning Aug 5, 2019

Choose a reason for hiding this comment

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

I think we also need to update header-toolbar: https://github.com/WordPress/gutenberg/pull/16906/files#diff-dbd7e14b9675d5446422c008453093bbR91. Sorry I didn't realize that before.

editPost,
resetEditorBlocks,
} = dispatch( 'core/editor' );
Expand All @@ -166,6 +169,7 @@ export default compose( [
} = dispatch( 'core/edit-post' );

return {
clearSelectedBlock,
editTitle( title ) {
editPost( { title } );
},
Expand Down