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

Viewport jumps when handling long text #11

Open
Allerby opened this issue Jun 28, 2018 · 1 comment
Open

Viewport jumps when handling long text #11

Allerby opened this issue Jun 28, 2018 · 1 comment

Comments

@Allerby
Copy link

Allerby commented Jun 28, 2018

Firstly, thanks for this great addon wrapper!

I've just noticed what I think may be a bug when the simple-mde textarea gets provided a large string of text. When you scroll down the editor a little bit, then start editing - the viewport jumps to put the cursor at the bottom of the page. Behavior can be seen In the twiddle below:

https://ember-twiddle.com/cdde8fcc6b9a1b1136f681316d1b380f?openFiles=controllers.application.js%2C

@marceloandrader
Copy link
Member

Hey @Allerby I was able to reproduce it locally too, I think the issue is in this lines:

https://github.com/smith-carson/ember-simplemde/blob/master/addon/components/simple-mde.js#L123-L125

We need to update the value on the editor from the value passed by the attribute value, to keep the cursor where it need to be I got the initial cursor, update the value, then set the cursor where it was (If not it will always take you to the beginning of the text)

I see that there is another function called setSelection that receive some options to avoid scroll, but I wasn't able to make it work. As always in open source pull requests are welcome.

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

No branches or pull requests

3 participants