Skip to content

Commit

Permalink
Fix editor losing focus after first word on Android. facebookarchive#907
Browse files Browse the repository at this point in the history
  • Loading branch information
mdarcemont committed May 3, 2017
1 parent 742c54f commit ba813d8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/component/base/DraftEditor.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const handlerMap = {
};

type State = {
containerKey: number,
contentsKey: number,
};

/**
Expand Down Expand Up @@ -171,7 +171,7 @@ class DraftEditor extends React.Component {
this.onDragLeave = this._onDragLeave.bind(this);

// See `_restoreEditorDOM()`.
this.state = {containerKey: 0};
this.state = {contentsKey: 0};
}

/**
Expand Down Expand Up @@ -230,7 +230,6 @@ class DraftEditor extends React.Component {
{this._renderPlaceholder()}
<div
className={cx('DraftEditor/editorContainer')}
key={'editor' + this.state.containerKey}
ref="editorContainer">
<div
aria-activedescendant={
Expand Down Expand Up @@ -286,6 +285,7 @@ class DraftEditor extends React.Component {
customStyleFn={this.props.customStyleFn}
editorKey={this._editorKey}
editorState={this.props.editorState}
key={'contents' + this.state.contentsKey}
/>
</div>
</div>
Expand Down Expand Up @@ -392,7 +392,7 @@ class DraftEditor extends React.Component {
* occurs on a version of the DOM that is synchronized with our EditorState.
*/
_restoreEditorDOM(scrollPosition?: DraftScrollPosition): void {
this.setState({containerKey: this.state.containerKey + 1}, () => {
this.setState({contentsKey: this.state.contentsKey + 1}, () => {
this._focus(scrollPosition);
});
}
Expand Down

0 comments on commit ba813d8

Please sign in to comment.