Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Fix editor losing focus after first word on Android. #907

Merged
merged 5 commits into from
Feb 27, 2017
Merged
Changes from all 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
17 changes: 9 additions & 8 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 @@ -283,6 +282,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 @@ -383,13 +383,14 @@ class DraftEditor extends React.Component {
/**
* Used via `this.restoreEditorDOM()`.
*
* Force a complete re-render of the editor based on the current EditorState.
* This is useful when we know we are going to lose control of the DOM
* state (cut command, IME) and we want to make sure that reconciliation
* occurs on a version of the DOM that is synchronized with our EditorState.
* Force a complete re-render of the DraftEditorContents based on the current
* EditorState. This is useful when we know we are going to lose control of
* the DOM state (cut command, IME) and we want to make sure that
* reconciliation 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