Skip to content

Commit

Permalink
Fix exception when opening dev tools
Browse files Browse the repository at this point in the history
Apparently draft sometimes gets unhappy when you try to move to the
end of an empty state, so only move to the end if we actually
created a non-empty state.

This will be irrelevant once #1890
is merged, but I have the fix now, and this is probably otherwise
going to annoy me now I'm doing things where devtools is very useful.

Fixes element-hq/element-web#6436
  • Loading branch information
dbkr committed Jun 13, 2018
1 parent bfb535d commit b81e12e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/components/views/rooms/MessageComposerInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,14 @@ export default class MessageComposerInput extends React.Component {

let editorState = null;
if (contentState) {
editorState = EditorState.createWithContent(contentState, compositeDecorator);
editorState = EditorState.moveFocusToEnd(
EditorState.createWithContent(contentState, compositeDecorator)
);
} else {
editorState = EditorState.createEmpty(compositeDecorator);
}

return EditorState.moveFocusToEnd(editorState);
return editorState;
}

componentDidMount() {
Expand Down

0 comments on commit b81e12e

Please sign in to comment.