Skip to content

Commit

Permalink
Handle focusing on the editor line ourselves 🤷; fixes #39
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Jun 15, 2021
1 parent 8b17aa8 commit 27551df
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/TextEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ class TextEditor extends Component {
this.onChange = this.onChange.bind(this);
this.handleKeyCommand = this.handleKeyCommand.bind(this);
this.handleFormating = this.handleFormating.bind(this);
this.handleFocus = this.handleFocus.bind(this);
this.editorRef = React.createRef();
}

handleFocus() {
if (this.editorRef.current) this.editorRef.current.focus();
}

/** */
Expand Down Expand Up @@ -58,6 +64,7 @@ class TextEditor extends Component {
const { classes } = this.props;
const { editorState } = this.state;
const currentStyle = editorState.getCurrentInlineStyle();

return (
<div>
<ToggleButtonGroup
Expand All @@ -77,11 +84,12 @@ class TextEditor extends Component {
<ItalicIcon />
</ToggleButton>
</ToggleButtonGroup>
<div className={classes.editorRoot}>
<div className={classes.editorRoot} onClick={this.handleFocus}>
<Editor
editorState={editorState}
handleKeyCommand={this.handleKeyCommand}
onChange={this.onChange}
ref={this.editorRef}
/>
</div>
</div>
Expand Down

0 comments on commit 27551df

Please sign in to comment.