Skip to content

Focus lost after typing character #151

Description

@alchy58

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions