Skip to content

Cursor jumps to end of editorComponent text field in v2.10.97 #5092

@mikestopcontinues

Description

@mikestopcontinues

Describe the bug

It looks like bugs #4539 and #3578 have returned.

To Reproduce

  1. Register editorComponent with text field (below).
  2. Create document, add component, add text to text field.
  3. Move pointer to anywhere but the end of the text field input.
  4. Try to type.
  5. After one character, the cursor jumps to the end.
const typeToPre = { bonus: '+>', info: '!>', warning: '?>', error: '#>', }; const preToType = R.zipObj(R.values(typeToPre), R.keys(typeToPre)); CMS.registerEditorComponent({ id: 'hint', label: 'Hint', fields: [ F.select({label: 'Type', name: 'type', options: R.keys(typeToPre)}), F.text({label: 'Text', name: 'text'}), ], pattern: /^([!#+?]>) (.+)$/, fromBlock([_, pre, text]) { return {type: preToType[pre], text}; }, toBlock({type, text = ''}) { return `${typeToPre[type]} ${text}`; }, toPreview({type, text = ''}) { return ( <p className={`hint ${type}`} dangerouslySetInnerHTML={{__html: text}} /> ); }, });

Expected behavior

I expect the cursor to hold its position.

Applicable Versions:

  • Netlify CMS version: 2.10.97
  • Git provider: Github
  • OS: OSX 11
  • Browser version Chrome 88
  • Node.JS version: 14.15.4

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions