Cursor jumps to end of editorComponent `text` field in v2.10.97
- Dominant language
- JavaScript
- Stars
- 19.4k
- Forks
- 3.1k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 9
Description
**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.
```js
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 (
);
},
});
```
**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
Contributor guide
Assessment
This issue has not been assessed yet.