Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Focus lost after typing character #151

Open
alchy58 opened this issue Apr 14, 2019 · 2 comments
Open

Focus lost after typing character #151

alchy58 opened this issue Apr 14, 2019 · 2 comments

Comments

@alchy58
Copy link

alchy58 commented Apr 14, 2019

Hi,
I'm facing a strange issue, I suppose I did something wrong.
When I type a character, I lost the focus on the editor. Moreover, the autoFocus option did work so I need to click inside the editor before typing.
What have I missed ?

I'm using react-codemirror 1.0.0

import React from 'react'
import ReactMarkdown from 'react-markdown'
import CodeMirror from 'react-codemirror'
import 'codemirror/mode/markdown/markdown'

export default class TopicContentComponent extends React.Component {
    constructor(props) {
        super(props);

        this.state = {
            source: props.source,
        }
    }

    render () {
        const options = {
            lineNumbers: true,
            autoFocus: true,
            mode: 'markdown',
            theme: 'monokai',
        }

        const Preview = () => <ReactMarkdown source={this.state.source} />
        const Editor = () =>
            <CodeMirror
                value={this.state.source}
                onChange={(source) => this.setState({source})}
                options={options}
            />

        return (
            <div>
                <Preview />
                <Editor />
            </div>
        )
    }
}

Thank you

@Eshaan1999
Copy link

I am facing the same issue as well , the state change is causing this issue but i am unable to find a workaround.

@marabesi
Copy link

+1 on this one

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

No branches or pull requests

3 participants