Skip to content

Snippets do not work properly when accessing state in onchange event #258

Open
@parahippo

Description

@parahippo

I came across some unusual behavior trying out this component: snippet functionality gets partially disabled when using this component and updating state in a onchange handler. The first term in the snippet is highlighted but the subsequent terms are not and you can't tab through them. I am new to React so it's entirely possible I am not using state properly or the component properly but I could not figure out why this was happening. I created my own react component with codemirror and it worked properly, so I thought I should report this as a potential bug. I created two sandboxes below to demonstrate the issue. Just start typing and complete the ".testSnippet" and it should be obvious.

Snippets with the react-codemirror component (snippets do not work properly, only the first term is highlighted and you can't tab through the rest):
React Codemirror Sandbox Demo
If you comment out line 32, then it works properly, so it's something having to do with the state.

Snippets with a customer codemirror component (snippets work properly):
Custom Codemirror Component Sandbox Demo

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions