diff --git a/src/component/base/DraftEditor.react.js b/src/component/base/DraftEditor.react.js index b5400d3969..aa04c44f57 100644 --- a/src/component/base/DraftEditor.react.js +++ b/src/component/base/DraftEditor.react.js @@ -80,42 +80,41 @@ class UpdateDraftEditorFlags extends React.Component<{ } _update() { const editor = this.props.editor; - if (gkx('draft_js_remove_componentwillupdate')) { - /** - * Sometimes a render triggers a 'focus' or other event, and that will - * schedule a second render pass. - * In order to make sure the second render pass gets the latest editor - * state, we update it here. - * Example: - * render #1 - * + - * | - * | cWU -> Nothing ... latestEditorState = STALE_STATE :( - * | - * | render -> this.props.editorState = FRESH_STATE - * | + *and* set latestEditorState = FRESH_STATE - * | - * | | - * | +--> triggers 'focus' event, calling 'handleFocus' with latestEditorState - * | + - * | | - * +>cdU -> latestEditorState = FRESH_STATE | the 'handleFocus' call schedules render #2 - * | with latestEditorState, which is FRESH_STATE - * | - * render #2 <--------------------------------------+ - * + - * | - * | cwU -> nothing updates - * | - * | render -> this.props.editorState = FRESH_STATE which was passed in above - * | - * +>cdU fires and resets latestEditorState = FRESH_STATE - * --- - * Note that if we don't set latestEditorState in 'render' in the above - * diagram, then STALE_STATE gets passed to render #2. - */ - editor._latestEditorState = this.props.editorState; - } + /** + * Sometimes a render triggers a 'focus' or other event, and that will + * schedule a second render pass. + * In order to make sure the second render pass gets the latest editor + * state, we update it here. + * Example: + * render #1 + * + + * | + * | cWU -> Nothing ... latestEditorState = STALE_STATE :( + * | + * | render -> this.props.editorState = FRESH_STATE + * | + *and* set latestEditorState = FRESH_STATE + * | + * | | + * | +--> triggers 'focus' event, calling 'handleFocus' with latestEditorState + * | + + * | | + * +>cdU -> latestEditorState = FRESH_STATE | the 'handleFocus' call schedules render #2 + * | with latestEditorState, which is FRESH_STATE + * | + * render #2 <--------------------------------------+ + * + + * | + * | cwU -> nothing updates + * | + * | render -> this.props.editorState = FRESH_STATE which was passed in above + * | + * +>cdU fires and resets latestEditorState = FRESH_STATE + * --- + * Note that if we don't set latestEditorState in 'render' in the above + * diagram, then STALE_STATE gets passed to render #2. + */ + editor._latestEditorState = this.props.editorState; + /** * The reason we set this 'blockSelectEvents' flag is that IE will fire a * 'selectionChange' event when we programmatically change the selection, @@ -444,26 +443,10 @@ class DraftEditor extends React.Component { } } - /** - * Prevent selection events from affecting the current editor state. This - * is mostly intended to defend against IE, which fires off `selectionchange` - * events regardless of whether the selection is set via the browser or - * programmatically. We only care about selection events that occur because - * of browser interaction, not re-renders and forced selections. - */ - componentWillUpdate(nextProps: DraftEditorProps): void { - if (!gkx('draft_js_remove_componentwillupdate')) { - // we are using the GK to phase out setting this here - this._latestEditorState = nextProps.editorState; - } - } - componentDidUpdate(): void { this._blockSelectEvents = false; - if (gkx('draft_js_remove_componentwillupdate')) { - // moving this here, when it was previously set in componentWillUpdate - this._latestEditorState = this.props.editorState; - } + // moving this here, when it was previously set in componentWillUpdate + this._latestEditorState = this.props.editorState; this._latestCommittedEditorState = this.props.editorState; }