Skip to content
This repository has been archived by the owner on Mar 29, 2024. It is now read-only.

First click on side buttons make the element disappear #38

Closed
codeKonami opened this issue Nov 30, 2016 · 4 comments
Closed

First click on side buttons make the element disappear #38

codeKonami opened this issue Nov 30, 2016 · 4 comments

Comments

@codeKonami
Copy link

When you load the page and click directly on the side buttons the element disappear completely.

Bug

@brijeshb42
Copy link
Owner

brijeshb42 commented Dec 1, 2016

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
@yachtingchen
Copy link

yachtingchen commented Feb 17, 2017

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;

@yachtingchen
Copy link

yachtingchen commented Feb 22, 2017

Similar problem happened when the cursor is in "image caption" and then press "Enter"

disapear

@J00nz
Copy link
Contributor

J00nz commented Mar 22, 2017

#62

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants