tinymce-angular icon indicating copy to clipboard operation
tinymce-angular copied to clipboard

Updating content externally causes cursor to jump to beginning

Open andyrue opened this issue 3 years ago • 5 comments

What is the current behavior?

I'm updating an editor linked to a formControl through external means, and the cursor jumps to the beginning when an update is triggered. I don't experience this behavior using something like a basic textarea, or other directives like an Angular Material matInput on a textarea.

Please provide the steps to reproduce and if possible a minimal demo of the problem via [codesandbox.io]

This example shows the problem. I understand the example is unorthodox, but in my case patchValue is being triggered from a websocket, so it makes more sense. https://codesandbox.io/s/tinymce-angular-forked-sdwgoj

What is the expected behavior?

The cursor should stay where it was.

Which versions of TinyMCE/TinyMCE-Angular, and which browser / OS are affected by this issue? Did this work in previous versions of TinyMCE or TinyMCE-Angular?

Seems to affect all browsers. [email protected] [email protected]

andyrue avatar Oct 20 '22 13:10 andyrue

Ref: INT-3036

exalate-issue-sync[bot] avatar Oct 20 '22 13:10 exalate-issue-sync[bot]

The problem with situations like this is that completely different content might be coming from the pipeline and it is wild to magically place the caret where a user think it should be. So, of course every time the content changes is a clear slate and start from the beginning. At best, the component could do a best effort to place it in the same position if the content has not changed at all.

jscasca avatar Oct 21 '22 06:10 jscasca

Thanks for looking. That does make sense, but how come something like a textarea works as expected? This example has both. https://codesandbox.io/s/tinymce-angular-forked-96s50w

andyrue avatar Oct 21 '22 11:10 andyrue

I have the same issue.

In my case it's because I have an autosave mechanism that saves every x seconds. The saving is done in the server and the saved content is sent back to the formControl which resets the cursor everytime.

I was upgrading from a simple textarea to tinymce and this is the main reason that I can't continue working on the tinymce integration. Would be nice to have a solution or workaround for this.

ferlimputra avatar Jun 30 '23 11:06 ferlimputra

This bug is annoying also me: opened a PR.

davidediak avatar Feb 07 '24 13:02 davidediak

This issue is stale because it has been open 30 days with no activity. Please comment if you wish to keep this issue open or it will be closed in 7 days.

tiny-stale-bot avatar Jul 09 '24 00:07 tiny-stale-bot

This issue is stale because it has been open 30 days with no activity. Please comment if you wish to keep this issue open or it will be closed in 7 days.

tiny-stale-bot avatar Aug 09 '24 00:08 tiny-stale-bot

This issue was closed because it has been stalled for 7 days with no activity.

tiny-stale-bot avatar Aug 16 '24 00:08 tiny-stale-bot