This repository has been archived by the owner on Mar 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 244
First click on side buttons make the element disappear #38
Comments
I have also observed this behavior. I am not sure why this occurs. Something related to draft's selection collapse maybe. |
codeKonami
added a commit
to codeKonami/medium-draft
that referenced
this issue
Dec 1, 2016
Here is a simple workaround for this problem import React from 'react';
import {
Editor,
createEditorState,
} from 'medium-draft';
class MediumEditor extends React.Component {
constructor(props) {
super(props);
this.state = {
editorState: createEditorState(),
hideWorkaround: false
};
this.onChange = (editorState) => {
this.setState({ editorState });
};
}
componentDidMount() {
this.refs.editor.focus();
/* ===== workaround code start ===== */
setTimeout(() => this.refs.workaround.focus(), 50);
setTimeout(() => this.refs.editor.focus(), 100);
setTimeout(() => this.setState({hideWorkaround: true}), 70);
/* ===== workaround code end ===== */
}
render() {
const { editorState } = this.state;
return (
<div>
<input hidden={this.state.hideWorkaround} ref="workaround" />
<Editor
ref="editor"
editorState={editorState}
onChange={this.onChange} />
</div>
);
}
}
export default MediumEditor; |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
When you load the page and click directly on the side buttons the element disappear completely.
The text was updated successfully, but these errors were encountered: