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 repositioned while editing example #139

Closed
AoDev opened this issue May 1, 2016 · 7 comments · Fixed by #145
Closed

Cursor repositioned while editing example #139

AoDev opened this issue May 1, 2016 · 7 comments · Fixed by #145
Labels

Comments

@AoDev
Copy link
Contributor

AoDev commented May 1, 2016

Hello,

When editing a live snippet the cursor will sometimes be repositioned at the beginning of the snippet.

It is annoying because the snippet will break while typing. Plus, you have to correct the "mess" before continuing.

My first guess is maybe because react is re-rendering, so the mouse cursor is moved at the beginning?

@sapegin
Copy link
Member

sapegin commented May 1, 2016

I’ve noticed it recently and looks like it’s something relatively new. But I haven’t had time to investigate it yet.

@sapegin sapegin added the bug label May 1, 2016
@mik01aj
Copy link
Collaborator

mik01aj commented May 4, 2016

It's not new, I noticed it sometimes in 1.x too. Looks like before first code change in CodeMirror the cursor position is calculated using some smaller font-size.

Ah, or wait, maybe we're speaking about 2 different bugs...

Btw, I also noticed the repositioning to the beginning as @AoDev describes, this makes it hard to type in the examples.

@tizmagik
Copy link
Collaborator

Having the same issue. I'm glad it's not just me. Any idea when this started happening? Maybe we can nail down the exact change?

I noticed it also only happens when you type quickly. If you type very slowly it doesn't seem to happen, which makes me think it has something to do with the timing of re-rendering the component while typing in the codemirror box.

@AoDev
Copy link
Contributor Author

AoDev commented May 16, 2016

While investigating, I've seen that changing the debouncing delay of the editor to 1000 ms prevents this from happening. https://github.com/sapegin/react-styleguidist/blob/master/src/rsg-components/Editor/Editor.js#L14

But the update is delayed.

@mik01aj
Copy link
Collaborator

mik01aj commented May 17, 2016

Imho it's fine to delay the update but I will not give my 👍 until we actually UNDERSTAND why this happens. (Nailing down the commit with git bisect would be enough I guess).

@AoDev
Copy link
Contributor Author

AoDev commented May 17, 2016

Sure, just giving some hints.

@mik01aj mik01aj changed the title Mouse cursor repositioned while editing example Cursor repositioned while editing example May 17, 2016
@tizmagik
Copy link
Collaborator

Submitted #145 to address this. Details about why this happens written there.

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

Successfully merging a pull request may close this issue.

4 participants