Skip to content

Commit

Permalink
Call blur when deselecting RichText or PlainText component. (#12765)
Browse files Browse the repository at this point in the history
This is required to hide the keyboard when the focus moves to a non textual block.
  • Loading branch information
daniloercoli committed Dec 11, 2018
1 parent b9e9afd commit fa5cff9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/editor/src/components/plain-text/index.native.js
Expand Up @@ -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();
}
Expand Down
2 changes: 2 additions & 0 deletions packages/editor/src/components/rich-text/index.native.js
Expand Up @@ -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();
}
}

Expand Down

0 comments on commit fa5cff9

Please sign in to comment.