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

Window scroll position jumps wildly when typing into bottom of long body of text #114

Closed
jywarren opened this issue Nov 22, 2017 · 24 comments
Assignees

Comments

@jywarren
Copy link
Member

In Markdown mode, if you go to https://publiclab.github.io/PublicLab.Editor/examples/ and enter a few hundred lines of text -- just paste in a lot -- then type near the bottom, the scroll position starts to jump around, making it very hard to enter text.

I think this may have to do with the calculation of scrollTop on this line:

document.body.scrollTop = _module.scrollTop;

scrollTop also appears on these lines:

https://github.com/publiclab/PublicLab.Editor/search?utf8=%E2%9C%93&q=scroll&type=

Perhaps we're miscalculating, or maybe we shouldn't try to do this at all? We could test this by manually running setting document.body.scrollTop and/or by inserting console.log statements by these probable lines, to check when they're being set and by how much.

This needs some exploration to figure out exactly what's causing this!

@jywarren
Copy link
Member Author

jywarren commented Dec 5, 2017

Related upstream but in Woofmark? bevacqua/woofmark#26

@kunal-mohta
Copy link
Contributor

Do you have to resize the the textarea?
If we disable resize, we get this..
screencast-2018-01-24-01-28-39

..which seems pretty decent.

(My apologies for the poor quality of the gif, you can also view the result in the video present in the zip folder below)
Screencast 2018-01-24 01:28:39.mp4.tar.gz

@jywarren
Copy link
Member Author

I think it's just trying to emulate the behavior of the rich text mode... see how it's different there? But maybe if we're seeing bad behavior here we should just disable it for now and ensure it's "pretty tall" ... what do you think?

@kunal-mohta
Copy link
Contributor

Oh I see..
I think you are right, instead of disabling resize, we could try to fix the automatic scrolling of the page on entering text, right?

@jywarren
Copy link
Member Author

jywarren commented Jan 25, 2018 via email

@shapironick
Copy link

+1ing this issue :) as it makes writing intricate notes frustrating.

@ebarry
Copy link
Member

ebarry commented Apr 24, 2018

Hi! I'm also experiencing this. Whenever i do a key command like ⌘b to bold some text, or click the B button, the page positions moves to the bottom of the page -- past the text window all the way to the bottom of the footer. @SidharthBansal do you have any ideas on this?

@SidharthBansal
Copy link
Member

@ebarry on clicking on the bold button B I did not notice any movement of the page to the bottom of the page. I also tried with the ⌘b that also works well. I am using Ubuntu with Mozilla Firefox. Maybe the problem is with the browser.

@ebarry
Copy link
Member

ebarry commented Apr 24, 2018

Wow that is great to hear. Can i ask if you tested with several hundred lines of text that caused the entry box to be greatly expanded, like as much as https://publiclab.org/notes/liz/04-24-2018/evaluation-listen4good-round-two-results ?

@SidharthBansal
Copy link
Member

SidharthBansal commented Apr 24, 2018

I tried with the link provided by you but the behaviour is normal in case of bold button and ⌘b

@ebarry
Copy link
Member

ebarry commented Apr 24, 2018

wow ok! Time to switch to Ubuntu!!! I will try to better document this for other browsers

@jywarren
Copy link
Member Author

jywarren commented Apr 24, 2018 via email

@ebarry
Copy link
Member

ebarry commented Apr 25, 2018

Aha! new information to report:

in Chrome, when editing a large amount of text, and with a cursor position "below the fold" (somewhere lower than what is shown upon first load of the Editor interface) ---> pressing EITHER the shift key OR the command key (⌘ on mac) causes the page to "move" all the way down to the bottom of the footer, past even the lower boundary of the text box.

Use this text file for testing (it's the entire content in markdown for https://publiclab.org/notes/liz/04-24-2018/evaluation-listen4good-round-two-results):
example text.txt

@jywarren
Copy link
Member Author

jywarren commented Jun 5, 2018

I think we could try to reproduce this by:

  1. console.log()ing this line to see what the scrollTop values are:
    document.body.scrollTop = _module.scrollTop;
  2. instead of pressing shift or command as Liz says, trying to trigger this by manually entering the same values for scrollTop that are being input by the above command, in the JS console
  3. observing if this does indeed incorrectly scroll the editor to a bad place as Liz has documented
  4. trying to understand why this bad scrollTop position is given and in what conditions
  5. trying to either stop it from triggering a new scrollTop in that moment, or try to get a better value for scrollTop when it does.

@jywarren
Copy link
Member Author

jywarren commented Jun 5, 2018

We can also try to just disable changing scrollTop but not disabling the resizing altogether to see if that helps?

@jywarren
Copy link
Member Author

jywarren commented Jun 5, 2018

@publiclab/soc if anyone likes JavaScript and is looking for a small side project, this one is pretty frustrating if you've ever written a long post on PublicLab.org! Any help appreciated. 😅

@jywarren
Copy link
Member Author

jywarren commented Jun 5, 2018

We also use the npm module grow-textarea to do this, and maybe that's buggy:

var growTextarea = require('grow-textarea');
// Make textarea match content height
_module.resize = function() {
growTextarea(_module.options.textarea, { extra: 10 });
}

Here are some others we might try:

@jywarren
Copy link
Member Author

jywarren commented Jun 5, 2018

I think we have to figure out if the scrollTop line is causing this or the grow-textarea library. We can try commenting out one or the other and testing this now that Liz has provided a long example text to use.

@ebarry
Copy link
Member

ebarry commented Aug 6, 2018

This is such a funny bug! While editing a long research note, even pressing Shift in order to capitalize a letter causes the rapid window scroll to the bottom. As soon as the second letter is typed, however, the window scrolls up rapidly to the correct cursor insert point in the text box (so rapidly, it is not immediately obvious what caused the flicker). Thanks for reading!

@jywarren
Copy link
Member Author

jywarren commented Aug 7, 2018

I disabled grow-textarea on line 136 of src/modules/PublicLab.RichTextModule.js and this behavior stopped. So I think it's worth trying a different textarea growing library.

@jywarren
Copy link
Member Author

jywarren commented Aug 7, 2018

Trying https://www.npmjs.com/package/autogrow now

jywarren added a commit to jywarren/PublicLab.Editor that referenced this issue Aug 7, 2018
jywarren added a commit to jywarren/PublicLab.Editor that referenced this issue Aug 7, 2018
@ghost ghost assigned jywarren Aug 7, 2018
@ghost ghost added the in progress label Aug 7, 2018
@jywarren
Copy link
Member Author

jywarren commented Aug 7, 2018

I've attempted a fix by removing the autogrow feature completely, as suggested by @kunal-mohta. I've commented it out with a note as to why. Tests running...

@ghost ghost removed the in progress label Aug 7, 2018
@jywarren
Copy link
Member Author

jywarren commented Aug 7, 2018

Merging and publishing

@ebarry
Copy link
Member

ebarry commented Aug 7, 2018 via email

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

5 participants