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

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

Open
mikestopcontinues opened this issue Mar 11, 2021 · 34 comments
Open
Labels
area: extensions/editor-components pinned type: bug code to address defects in shipped code

Comments

@mikestopcontinues
Copy link

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
@erezrokah
Copy link
Contributor

erezrokah commented Mar 11, 2021

Hi @mikestopcontinues, I was unable to reproduce this using your example (the cursor doesn't jump for me).

Also, this doesn't happen with any of the blocks in https://cms-demo.netlify.com/#/collections/posts/new.

Perhaps share a public repo and a video/gif showing the issue?

@mikestopcontinues
Copy link
Author

Hi @erezrokah Here's a reproduction. Sorry I didn't lead with one. In my own experimentation, it's only the text field. The others aren't giving me a problem.

https://codepen.io/mikestopcontinues/pen/PobXQxO

And here's the goal state, which does some parsing to/from markdown. The issue is the same. Including it just for context.

https://codepen.io/mikestopcontinues/pen/QWGzQOr

@ChrisPJohn
Copy link

I'm also experiencing cursor jumping to the end of text fields that are inside a component in markdown.

I'm using:
netlify-cms-app@^2.14.26
Chrome 89.0.4389.82
OS: Windows

@josephmasongsong
Copy link

josephmasongsong commented Sep 11, 2022

App recently started experiencing this behaviour, any updates on the issue?

netlify-cms-app@^2.15.72
OS: macOS Monterey
Chrome Version 105.0.5195.102 (Official Build) (arm64)

For what it's worth it is not happening in Safari.

@carlfredrikhero
Copy link

carlfredrikhero commented Sep 12, 2022

I can confirm @josephmasongsong report that this bug is active again.

netlify-cms@2.10.192
OS: macOS Monterey
Chrome: Version 105.0.5195.102 (Official Build) (arm64)

Firefox (104.0.2 (64-bit)) does not have the issue.

@aloverso
Copy link

My team is seeing this bug as well. I was not seeing it, and then I updated to Chrome Version 105.0.5195.102, and then I was seeing it. Looks like it has something to do with the newest version of Chrome

@tonyshearer
Copy link

tonyshearer commented Sep 13, 2022

I'm getting this too, starting from when I upgraded to Chrome 105.0.5195.102 (Official Build) (x86_64).

netlify-cms-app 2.15.72
netlify-cms-core 2.55.2
netlify-cms 2.10.192

CMS.cursor.prob.mov

@johnxie
Copy link

johnxie commented Sep 14, 2022

Friendly bump on this issue, our content team started experiencing this issue after upgrading to Chrome 105.

@johnxie
Copy link

johnxie commented Sep 14, 2022

Update from our team. It looks like removing this line will fix the issue.

screen_shot_2022-09-14_at_2 46 02_am

Video attached

Sep-14-2022.02-44-52.mp4

@h1sashin
Copy link

Update from our team. It looks like removing this line will fix the issue.

screen_shot_2022-09-14_at_2 46 02_am

Video attached

Sep-14-2022.02-44-52.mp4

yes but can I remove it globally?

@aledovskikh
Copy link

I think the proper fix for now is

[data-slate-editor] { 
    -webkit-user-modify: read-write !important; 
}

@h1sashin
Copy link

h1sashin commented Sep 14, 2022

I think the proper fix for now is

[data-slate-editor] { 
    -webkit-user-modify: read-write !important; 
}

Thanks, I'll try it but hello Netlify, it's been 3 years since bug exists

@nirazul
Copy link
Contributor

nirazul commented Sep 14, 2022

@h1sashin
I wouldn't count on netlify providing anything cms related. They basically stopped developing it.

I've just struck the same bug and landed here on my research.

@VitroidFPV
Copy link

Same here on Brave 1.43.89 Chromium: 105.0.5195.102. Makes any kind of back-editing practically impossible without the fix provided by @johnxie and/or @aledovskikh

@keogh
Copy link

keogh commented Sep 22, 2022

Any plan on fixing this? is there a PR already?

I posted the same issue over here #6557

marcojakob added a commit to marcojakob/lilo.blog that referenced this issue Sep 22, 2022
@sawilde
Copy link

sawilde commented Sep 23, 2022

How do you apply the fix as I can't work that out? I am using netlify CMS with an 11ty site.

@marcojakob
Copy link

marcojakob commented Sep 23, 2022

How do you apply the fix as I can't work that out? I am using netlify CMS with an 11ty site.

@sawilde Add the following code in the header of the index.html file where the Netlify CMS JavaScript is loaded. That works for me:

<style>
[data-slate-editor] { 
    -webkit-user-modify: read-write !important; 
}
</style>

@sawilde
Copy link

sawilde commented Sep 23, 2022

@marcojakob thank you very much

@amantulsyan35
Copy link

I think the proper fix for now is

[data-slate-editor] { 
    -webkit-user-modify: read-write !important; 
}

Hi, I am using netlify CMS with gatsby js, and am confused how to apply this fix, can someone help me

@sawilde
Copy link

sawilde commented Sep 25, 2022

@amantulsyan35 I don't know how the gatsby setup works but in my setup I had an admin section with an index.html file that loads the Netlify CMS script, I added it in there as described by @marcojakob

image

@pjr94
Copy link

pjr94 commented Jun 9, 2023

Still an issue when using CDN version of CMS

@ashleykolodziej-moodys
Copy link

I'm still encountering this issue, and the above fix didn't work for me. I'm using a list widget as an editor component, and I have two text areas in each list item that are having this problem - a code widget, and a text widget. The string widget is working fine and doesn't jump the cursor to the end.

For the code widget, I was able to get the right behavior by using this CSS snippet in admin/index.html instead (notice the change in selector to textarea:

<style>
      /* Workaround for text editor https://github.com/decaporg/decap-cms/issues/5092 */
      textarea {
        -webkit-user-modify: read-write !important;
      }
</style>

However, I'm still having this problem with the text widget, and the original suggestion to use the [data-slate-editor] selector isn't working for me. Maybe there's something with how the list widget updates child items that doesn't work with this workaround for the text widget? If anyone has any leads on a fix for this situation, I'd appreciate it.

@kav
Copy link

kav commented Jun 24, 2023

This appears to be caused by ianstormtaylor/slate#5110 so the fix is likely upgrading the version of slate used by the netlify-cms-widget-markdown package. It's likely worth updating the recommended index.html with the workaround if upgrading slate isn't in the cards near term as this is a near universal issue at this point.

Happy to PR the workaround into the various docs, not sure I have the bandwidth to update Slate from 0.47 to 0.94 but if that's on the team's radar it's probably the better fix

@ali4zimi
Copy link

ali4zimi commented Jul 4, 2023

I think the proper fix for now is

[data-slate-editor] { 
    -webkit-user-modify: read-write !important; 
}

But here it is said that it is a non-standard feature and shouldn't be used for production sites.

@martinjagodic
Copy link
Member

@ali4zimi since this is only a css rule, I don't see why it wouldn't be used on production sites. I think it's safe.

@vhoyer
Copy link

vhoyer commented Jul 10, 2023

This appears to be caused by ianstormtaylor/slate#5110 so the fix is likely upgrading the version of slate used by the netlify-cms-widget-markdown package. It's likely worth updating the recommended index.html with the workaround if upgrading slate isn't in the cards near term as this is a near universal issue at this point.

Happy to PR the workaround into the various docs, not sure I have the bandwidth to update Slate from 0.47 to 0.94 but if that's on the team's radar it's probably the better fix

wait, what is the workaround? (because the css doesn't work with dead keys which is important for writing in portuguese and other languages as well)

@kav
Copy link

kav commented Jul 10, 2023

The workaround is the CSS change. It's not a fix but right now no one who freshly deploys according the documentation can use the markdown editor, in any language.

The correct fix is to update the library or make a new markdown control using a different library. I don't have the bandwidth to do that but @vhoyer given it's blocking you you might consider investigating that. Worth reviewing #5795 as it looks like there is some discussion about versions and switching editors there

SallyMcGrath added a commit to CodeYourFuture/CYF-PD that referenced this issue Jul 26, 2023
Fixes #16

A stale bug in Decap CMS. 3 Years old and unlikely to be fixed. Longer term as this system seems to be used, should either replace decap or vendorise and fix it.

decaporg/decap-cms#5092
xuerik pushed a commit to xuerik/budget-conscious-travelers that referenced this issue Sep 4, 2023
arthaud-proust added a commit to Hugolify/hugolify-netlify-cms that referenced this issue Nov 21, 2023
arthaud-proust added a commit to Hugolify/hugolify-netlify-cms that referenced this issue Nov 21, 2023
nsmmrs added a commit to strenuus/n360-cms-content that referenced this issue Jan 18, 2024
nsmmrs added a commit to strenuus/n360-cms-content that referenced this issue Jan 31, 2024
* Configure "Legacy Help Sections" resource to support importing existing content
* Output clean JSON files instead of relying on page-data artifacts
* Move search index to JSON pages
* Remove unused content and configuration
* Set up docker volumes for local development
* Add workaround for text editor cursor bug: decaporg/decap-cms#5092 (comment)
nsmmrs added a commit to strenuus/n360-cms-content that referenced this issue Feb 1, 2024
* Configure "Legacy Help Sections" resource to support importing existing content
* Publish clean JSON files instead of the whole page-data artifacts
* Remove unused content and configuration
* Set up docker volumes for local development
* Add workaround for text editor cursor bug: decaporg/decap-cms#5092 (comment)
nsmmrs added a commit to strenuus/n360-cms-content that referenced this issue Feb 1, 2024
* Configure "Legacy Help Sections" resource to support importing existing content
* Publish clean JSON files instead of the whole page-data artifacts
* Remove unused content and configuration
* Set up docker volumes for local development
* Add workaround for text editor cursor bug: decaporg/decap-cms#5092 (comment)
MrLeebo pushed a commit to strenuus/n360-cms-content that referenced this issue Feb 2, 2024
* Configure "Legacy Help Sections" resource to support importing existing content
* Publish clean JSON files instead of the whole page-data artifacts
* Remove unused content and configuration
* Set up docker volumes for local development
* Add workaround for text editor cursor bug: decaporg/decap-cms#5092 (comment)
@hiiiP0wer
Copy link

For those still facing this issue:

For Gatsby: (using gatsby-plugin-netlify-cms)

  1. Include this in gatsby-config.js:
    {
      resolve: 'gatsby-plugin-netlify-cms',
      options: {
        modulePath: `${__dirname}/src/cms/cms.js`
      }
    }
  1. Create the file referenced in modulePath prop above and add this in the cms/cms.js file:
const injectCustomStyle = () => {
  const style = document.createElement('style');
  style.innerHTML = `
    div[data-slate-editor] {
      -webkit-user-modify: read-write !important;
    }
  `;
  document.head.appendChild(style);
};

injectCustomStyle();

For others using index.html that loads the Netlify CMS script, this is very helpful: #5092 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: extensions/editor-components pinned type: bug code to address defects in shipped code
Projects
None yet
Development

No branches or pull requests