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

[Alpha] Hide the keyboard when tapping on non-inputField block #404

Merged
merged 4 commits into from
Dec 19, 2018
Merged
Changes from 2 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
14 changes: 13 additions & 1 deletion src/block-management/block-holder.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import styles from './block-holder.scss';
// Gutenberg imports
import { BlockEdit } from '@wordpress/editor';

import TextInputState from 'react-native/lib/TextInputState';

type PropsType = BlockType & {
isSelected: boolean,
showTitle: boolean,
Expand Down Expand Up @@ -106,7 +108,17 @@ export default compose( [
} = dispatch( 'core/editor' );

return {
onSelect: () => {
onSelect: (event) => {
if ( event ) {
// == Hack for the Alpha ==
// When moving the focus from a TextInput field to another kind of field the call that hides the keyboard is not invoked
// properly, resulting in keyboard up when it should not be there.
// The code below dismisses the keyboard (calling blur on the last TextInput field) when the field that now gets the focus is a non-textual field
const currentlyFocusedTextInput = TextInputState.currentlyFocusedField();
if ( event.nativeEvent.target !== currentlyFocusedTextInput && ! TextInputState.isTextInput( event.nativeEvent.target ) ) {
TextInputState.blurTextInput( currentlyFocusedTextInput );
}
}
clearSelectedBlock();
selectBlock( clientId );
},
Expand Down