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 position after calling setContents(delta) #1367

Closed
benbro opened this issue Mar 15, 2017 · 2 comments
Closed

Cursor position after calling setContents(delta) #1367

benbro opened this issue Mar 15, 2017 · 2 comments

Comments

@benbro
Copy link
Contributor

benbro commented Mar 15, 2017

I'm calling quill.setContents(delta) with a delta from OT server.
If the op is before the cursor, it moves the cursor forward or backwards as expected.

If the op is after the cursor, it moves the cursor to the end. For example, if a user is typing and another user is clicking Enter at the end of the doc, the cursor will jump to the new line and will break the current line in the middle.

Should Quill keep the cursor at the current position if the op is at or after the cursor?
Or maybe I should transform the local selection as part of applying the remote delta?

Steps for Reproduction

  1. Visit http://codepen.io/anon/pen/KWXwgw
  2. Focus the editor at the end of the word "Hello" (before setTimeout is called)
  3. Wait 5 seconds, for the timeout to fire. updateContents will add 3 new lines and a word.

Expected behavior:
Cursor should stay at the same position, after the word Hello.

Actual behavior:
Cursor jumps to the end of the document.

Platforms:
Firefox 52, Windows 7

Version:
1.2.2

@jhchen jhchen closed this as completed in 8765636 May 28, 2017
@nipunjain87
Copy link

nipunjain87 commented Aug 16, 2017

Resolving this issue has created another issue.
If we add an image to rich-text-editor using image toolbar, the cursor should move at end of image. But it is maintaining it's position.
This is not user friendly as user normally moves forward and he/she will have to manually click after the
image to continue adding content.

Compare below mentioned pens:-

  1. Version 1.2.5: https://codepen.io/anon/pen/qXVoJN
  2. version 1.2.2: http://codepen.io/anon/pen/KWXwgw

Steps:

  1. Place the cusror somewhere in editor.
  2. Upload image using image toolbar
  3. In Pen1, the cursor will remain at its position, while in pen2, it would go after image.

This issue was not present in build no 1.2.4 and got introduced in 1.2.5.

@jhchen
Copy link
Member

jhchen commented Aug 17, 2017

Can you make a separate issue @nipunjain87 for tracking?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants