decap-cms icon indicating copy to clipboard operation
decap-cms copied to clipboard

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

Open mikestopcontinues opened this issue 5 years ago • 34 comments

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

mikestopcontinues avatar Mar 11 '21 07:03 mikestopcontinues

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?

erezrokah avatar Mar 11 '21 11:03 erezrokah

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

mikestopcontinues avatar Mar 11 '21 13:03 mikestopcontinues

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

ChrisPJohn avatar Mar 13 '21 06:03 ChrisPJohn

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.

josephmasongsong avatar Sep 11 '22 22:09 josephmasongsong

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

[email protected] OS: macOS Monterey Chrome: Version 105.0.5195.102 (Official Build) (arm64)

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

carlfredrikhero avatar Sep 12 '22 09:09 carlfredrikhero

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

aloverso avatar Sep 12 '22 21:09 aloverso

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

https://user-images.githubusercontent.com/5812027/189841849-4b872744-57cf-4429-b142-0bad1f96bcd6.mov

tonyshearer avatar Sep 13 '22 07:09 tonyshearer

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

johnxie avatar Sep 14 '22 06:09 johnxie

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

https://user-images.githubusercontent.com/792088/190082126-d13eb60b-023b-45ca-9f8a-6365119e0eb9.mp4

johnxie avatar Sep 14 '22 06:09 johnxie

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?

h1sashin avatar Sep 14 '22 09:09 h1sashin

I think the proper fix for now is

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

aledovskikh avatar Sep 14 '22 09:09 aledovskikh

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

h1sashin avatar Sep 14 '22 10:09 h1sashin

@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.

nirazul avatar Sep 14 '22 17:09 nirazul

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

VitroidFPV avatar Sep 15 '22 17:09 VitroidFPV

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

I posted the same issue over here #6557

keogh avatar Sep 22 '22 13:09 keogh

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

sawilde avatar Sep 23 '22 12:09 sawilde

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>

marcojakob avatar Sep 23 '22 14:09 marcojakob

@marcojakob thank you very much

sawilde avatar Sep 23 '22 21:09 sawilde

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

amantulsyan35 avatar Sep 24 '22 17:09 amantulsyan35

@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

sawilde avatar Sep 25 '22 07:09 sawilde

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 @amantulsyan35

I used this solution for Gatsby.

https://answers.netlify.com/t/change-admin-css-to-tweak-a-bit-the-cms-ui-defaults/17835

josephmasongsong avatar Oct 26 '22 06:10 josephmasongsong

Experiencing this on our end as well, occurring in the markdown widget. Applying the style fix noted here fixes it for us.

Using Chrome Version 107.0.5304.87 (Official Build) (arm64)

JKarlavige avatar Nov 08 '22 21:11 JKarlavige

This solution doesn't work for me, when I need to write with dead keys (pt-BR with accent marks, and what not)

Outlook for Androidhttps://aka.ms/AAb9ysgを取得


From: Jason Karlavige @.> Sent: Tuesday, November 8, 2022 6:41:02 PM To: netlify/netlify-cms @.> Cc: Vinícius Hoyer @.>; Manual @.> Subject: Re: [netlify/netlify-cms] Cursor jumps to end of editorComponent text field in v2.10.97 (#5092)

Experiencing this on our end as well, occurring in the markdown widget. Applying the style fix noted here fixes it for us.

Using Chrome Version 107.0.5304.87 (Official Build) (arm64)

― Reply to this email directly, view it on GitHubhttps://github.com/netlify/netlify-cms/issues/5092#issuecomment-1307864982, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACUDBAADA335HUCQRKRD433WHLCG5ANCNFSM4Y7XZBEA. You are receiving this because you are subscribed to this thread.Message ID: @.***>

vhoyer avatar Nov 08 '22 23:11 vhoyer

The solution works, just don't forget to import the cms-utils.js into your cms.js file

nejurgis avatar Nov 29 '22 18:11 nejurgis

Is this issue fixed now? Is the style fix not needed anymore?

alianza avatar Apr 13 '23 23:04 alianza

Still happening on chrome on Windows and MacOS. Adding the snippet to the header fixed it for me using the Next.js template referenced in the docs.

FrankFlitton avatar Apr 18 '23 18:04 FrankFlitton

Still an issue when using CDN version of CMS

pjr94 avatar Jun 09 '23 09:06 pjr94

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.

ashleykolodziej-moodys avatar Jun 16 '23 17:06 ashleykolodziej-moodys

This appears to be caused by https://github.com/ianstormtaylor/slate/issues/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

kav avatar Jun 24 '23 23:06 kav

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.

ali4zimi avatar Jul 04 '23 16:07 ali4zimi