From 38ce6dbbd7e5dd09fe945add07e7991446dd6601 Mon Sep 17 00:00:00 2001 From: Danilo Ercoli Date: Mon, 10 Dec 2018 17:21:27 +0100 Subject: [PATCH] Call blur when deselecting RichText or PlainText component. This is required to hide the keyboard when the focus moves to a non textual block. --- packages/editor/src/components/plain-text/index.native.js | 6 ++++++ packages/editor/src/components/rich-text/index.native.js | 2 ++ 2 files changed, 8 insertions(+) diff --git a/packages/editor/src/components/plain-text/index.native.js b/packages/editor/src/components/plain-text/index.native.js index f7b923b5b976f..2373f85ea5815 100644 --- a/packages/editor/src/components/plain-text/index.native.js +++ b/packages/editor/src/components/plain-text/index.native.js @@ -21,6 +21,12 @@ export default class PlainText extends Component { } } + componentDidUpdate( prevProps ) { + if ( ! this.props.isSelected && prevProps.isSelected ) { + this._input.blur(); + } + } + focus() { this._input.focus(); } diff --git a/packages/editor/src/components/rich-text/index.native.js b/packages/editor/src/components/rich-text/index.native.js index 362dc4b359d1a..d909063d832a7 100644 --- a/packages/editor/src/components/rich-text/index.native.js +++ b/packages/editor/src/components/rich-text/index.native.js @@ -292,6 +292,8 @@ export class RichText extends Component { componentDidUpdate( prevProps ) { if ( this.props.isSelected && ! prevProps.isSelected ) { this._editor.focus(); + } else if ( ! this.props.isSelected && prevProps.isSelected ) { + this._editor.blur(); } }